From 64b3ebf83ecce69070bba65ccb57a29ed16fa574 Mon Sep 17 00:00:00 2001 From: Akhil Kumar P <36399231+akhilkumarpilli@users.noreply.github.com> Date: Thu, 18 Jul 2024 19:13:03 +0530 Subject: [PATCH 01/50] chore(confix): remove gas-adjustment in v0.52 client toml (#20988) --- tools/confix/data/v0.52-client.toml | 3 --- 1 file changed, 3 deletions(-) diff --git a/tools/confix/data/v0.52-client.toml b/tools/confix/data/v0.52-client.toml index d89c2092f4a0..785ecf499cde 100644 --- a/tools/confix/data/v0.52-client.toml +++ b/tools/confix/data/v0.52-client.toml @@ -25,6 +25,3 @@ grpc-address = "" # Allow the gRPC client to connect over insecure channels. # It can be overwritten by the --grpc-insecure flag in each command. grpc-insecure = false -# This is default the gas adjustment factor used in tx commands. -# It can be overwritten by the --gas-adjustment flag in each tx command. -gas-adjustment = 1.5 From 2e0e6d87760425c06fe81b5d133f6963f8d6fb6a Mon Sep 17 00:00:00 2001 From: Aaron Craelius Date: Thu, 18 Jul 2024 18:30:49 +0200 Subject: [PATCH 02/50] refactor(depinject/appconfig): remove api module dependency (#20931) Co-authored-by: Marko Co-authored-by: Matt Kocubinski --- depinject/appconfig/config.go | 52 +- depinject/appconfig/v1alpha1/config.pb.go | 942 ++++++++++++++++++ depinject/appconfig/v1alpha1/module.pb.go | 893 +++++++++++++++++ depinject/appconfig/v1alpha1/query.pb.go | 537 ++++++++++ depinject/go.mod | 4 +- depinject/go.sum | 14 +- .../internal/appconfig/buf.gen.pulsar.yaml | 5 + depinject/internal/appconfig/buf.gen.yaml | 11 - depinject/internal/appconfig/buf.yaml | 2 + depinject/internal/appconfig/registry.go | 59 +- .../internal/appconfig/testpb/test.proto | 2 + .../internal/appconfig/testpb/test.pulsar.go | 14 +- .../internal/appconfiggogo/buf.gen.gogo.yaml | 5 + depinject/internal/appconfiggogo/buf.gen.yaml | 11 - depinject/internal/appconfiggogo/buf.yaml | 2 + .../internal/appconfiggogo/testpb/test.pb.go | 25 +- .../internal/appconfiggogo/testpb/test.proto | 2 + orm/go.mod | 1 + orm/go.sum | 9 + proto/cosmos/app/v1alpha1/config.proto | 2 +- proto/cosmos/app/v1alpha1/module.proto | 2 +- proto/cosmos/app/v1alpha1/query.proto | 2 +- runtime/v2/go.mod | 1 + runtime/v2/go.sum | 8 + 24 files changed, 2539 insertions(+), 66 deletions(-) create mode 100644 depinject/appconfig/v1alpha1/config.pb.go create mode 100644 depinject/appconfig/v1alpha1/module.pb.go create mode 100644 depinject/appconfig/v1alpha1/query.pb.go create mode 100644 depinject/internal/appconfig/buf.gen.pulsar.yaml delete mode 100644 depinject/internal/appconfig/buf.gen.yaml create mode 100644 depinject/internal/appconfiggogo/buf.gen.gogo.yaml delete mode 100644 depinject/internal/appconfiggogo/buf.gen.yaml diff --git a/depinject/appconfig/config.go b/depinject/appconfig/config.go index 39a6c6c695fa..a63799b1a36a 100644 --- a/depinject/appconfig/config.go +++ b/depinject/appconfig/config.go @@ -10,18 +10,28 @@ import ( "google.golang.org/protobuf/encoding/protojson" protov2 "google.golang.org/protobuf/proto" "google.golang.org/protobuf/reflect/protoreflect" + "google.golang.org/protobuf/types/dynamicpb" "google.golang.org/protobuf/types/known/anypb" "sigs.k8s.io/yaml" - appv1alpha1 "cosmossdk.io/api/cosmos/app/v1alpha1" "cosmossdk.io/depinject" + "cosmossdk.io/depinject/appconfig/v1alpha1" internal "cosmossdk.io/depinject/internal/appconfig" ) // LoadJSON loads an app config in JSON format. func LoadJSON(bz []byte) depinject.Config { - config := &appv1alpha1.Config{} - err := protojson.UnmarshalOptions{ + // in order to avoid a direct dependency on api types, but in order to also be able to support + // either gogo or google.golang.org/protobuf types, we use protojson and dynamicpb to unmarshal + // from JSON + resolver := gogoproto.HybridResolver + desc, err := resolver.FindDescriptorByName(protoreflect.FullName(gogoproto.MessageName(&v1alpha1.Config{}))) + if err != nil { + return depinject.Error(err) + } + + config := dynamicpb.NewMessage(desc.(protoreflect.MessageDescriptor)) + err = protojson.UnmarshalOptions{ Resolver: dynamicTypeResolver{resolver: gogoproto.HybridResolver}, }.Unmarshal(bz, config) if err != nil { @@ -51,9 +61,27 @@ func WrapAny(config protoreflect.ProtoMessage) *anypb.Any { return cfg } -// Compose composes a v1alpha1 app config into a container option by resolving -// the required modules and composing their options. -func Compose(appConfig *appv1alpha1.Config) depinject.Config { +// Compose composes an app config into a container option by resolving +// the required modules and composing their options. appConfig should be an instance +// of cosmos.app.v1alpha1.Config (it doesn't matter whether you use gogo proto or +// google.golang.org/protobuf types). +func Compose(appConfig gogoproto.Message) depinject.Config { + appConfigConcrete, ok := appConfig.(*v1alpha1.Config) + if !ok { + // we convert any other proto type that was passed (such as an api module type) to the concrete + // type we're using here + appConfigConcrete = &v1alpha1.Config{} + bz, err := gogoproto.Marshal(appConfig) + if err != nil { + return depinject.Error(err) + } + + err = gogoproto.Unmarshal(bz, appConfigConcrete) + if err != nil { + return depinject.Error(err) + } + } + opts := []depinject.Config{ depinject.Supply(appConfig), } @@ -63,7 +91,7 @@ func Compose(appConfig *appv1alpha1.Config) depinject.Config { return depinject.Error(err) } - for _, module := range appConfig.Modules { + for _, module := range appConfigConcrete.Modules { if module.Name == "" { return depinject.Error(fmt.Errorf("module is missing name")) } @@ -84,10 +112,14 @@ func Compose(appConfig *appv1alpha1.Config) depinject.Config { init, ok := modules[msgName] if !ok { if msgDesc, err := gogoproto.HybridResolver.FindDescriptorByName(protoreflect.FullName(msgName)); err == nil { - modDesc := protov2.GetExtension(msgDesc.Options(), appv1alpha1.E_Module).(*appv1alpha1.ModuleDescriptor) + modDesc, err := internal.GetModuleDescriptor(msgDesc) + if err != nil { + return depinject.Error(err) + } + if modDesc == nil { return depinject.Error(fmt.Errorf("no module registered for type URL %s and that protobuf type does not have the option %s\n\n%s", - module.Config.TypeUrl, appv1alpha1.E_Module.TypeDescriptor().FullName(), dumpRegisteredModules(modules))) + module.Config.TypeUrl, v1alpha1.E_Module.Name, dumpRegisteredModules(modules))) } return depinject.Error(fmt.Errorf("no module registered for type URL %s, did you forget to import %s: find more information on how to make a module ready for app wiring: https://docs.cosmos.network/main/building-modules/depinject\n\n%s", @@ -122,7 +154,7 @@ func Compose(appConfig *appv1alpha1.Config) depinject.Config { } } - for _, binding := range appConfig.GolangBindings { + for _, binding := range appConfigConcrete.GolangBindings { opts = append(opts, depinject.BindInterface(binding.InterfaceType, binding.Implementation)) } diff --git a/depinject/appconfig/v1alpha1/config.pb.go b/depinject/appconfig/v1alpha1/config.pb.go new file mode 100644 index 000000000000..838f6cf8fea3 --- /dev/null +++ b/depinject/appconfig/v1alpha1/config.pb.go @@ -0,0 +1,942 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: cosmos/app/v1alpha1/config.proto + +package v1alpha1 + +import ( + fmt "fmt" + proto "github.com/cosmos/gogoproto/proto" + any "github.com/cosmos/gogoproto/types/any" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// Config represents the configuration for a Cosmos SDK ABCI app. +// It is intended that all state machine logic including the version of +// baseapp and tx handlers (and possibly even Tendermint) that an app needs +// can be described in a config object. For compatibility, the framework should +// allow a mixture of declarative and imperative app wiring, however, apps +// that strive for the maximum ease of maintainability should be able to describe +// their state machine with a config object alone. +type Config struct { + // modules are the module configurations for the app. + Modules []*ModuleConfig `protobuf:"bytes,1,rep,name=modules,proto3" json:"modules,omitempty"` + // golang_bindings specifies explicit interface to implementation type bindings which + // depinject uses to resolve interface inputs to provider functions. The scope of this + // field's configuration is global (not module specific). + GolangBindings []*GolangBinding `protobuf:"bytes,2,rep,name=golang_bindings,json=golangBindings,proto3" json:"golang_bindings,omitempty"` +} + +func (m *Config) Reset() { *m = Config{} } +func (m *Config) String() string { return proto.CompactTextString(m) } +func (*Config) ProtoMessage() {} +func (*Config) Descriptor() ([]byte, []int) { + return fileDescriptor_5af1d229673256fa, []int{0} +} +func (m *Config) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Config) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Config.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *Config) XXX_Merge(src proto.Message) { + xxx_messageInfo_Config.Merge(m, src) +} +func (m *Config) XXX_Size() int { + return m.Size() +} +func (m *Config) XXX_DiscardUnknown() { + xxx_messageInfo_Config.DiscardUnknown(m) +} + +var xxx_messageInfo_Config proto.InternalMessageInfo + +func (m *Config) GetModules() []*ModuleConfig { + if m != nil { + return m.Modules + } + return nil +} + +func (m *Config) GetGolangBindings() []*GolangBinding { + if m != nil { + return m.GolangBindings + } + return nil +} + +// ModuleConfig is a module configuration for an app. +type ModuleConfig struct { + // name is the unique name of the module within the app. It should be a name + // that persists between different versions of a module so that modules + // can be smoothly upgraded to new versions. + // + // For example, for the module cosmos.bank.module.v1.Module, we may chose + // to simply name the module "bank" in the app. When we upgrade to + // cosmos.bank.module.v2.Module, the app-specific name "bank" stays the same + // and the framework knows that the v2 module should receive all the same state + // that the v1 module had. Note: modules should provide info on which versions + // they can migrate from in the ModuleDescriptor.can_migration_from field. + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` + // config is the config object for the module. Module config messages should + // define a ModuleDescriptor using the cosmos.app.v1alpha1.is_module extension. + Config *any.Any `protobuf:"bytes,2,opt,name=config,proto3" json:"config,omitempty"` + // golang_bindings specifies explicit interface to implementation type bindings which + // depinject uses to resolve interface inputs to provider functions. The scope of this + // field's configuration is module specific. + GolangBindings []*GolangBinding `protobuf:"bytes,3,rep,name=golang_bindings,json=golangBindings,proto3" json:"golang_bindings,omitempty"` +} + +func (m *ModuleConfig) Reset() { *m = ModuleConfig{} } +func (m *ModuleConfig) String() string { return proto.CompactTextString(m) } +func (*ModuleConfig) ProtoMessage() {} +func (*ModuleConfig) Descriptor() ([]byte, []int) { + return fileDescriptor_5af1d229673256fa, []int{1} +} +func (m *ModuleConfig) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *ModuleConfig) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_ModuleConfig.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *ModuleConfig) XXX_Merge(src proto.Message) { + xxx_messageInfo_ModuleConfig.Merge(m, src) +} +func (m *ModuleConfig) XXX_Size() int { + return m.Size() +} +func (m *ModuleConfig) XXX_DiscardUnknown() { + xxx_messageInfo_ModuleConfig.DiscardUnknown(m) +} + +var xxx_messageInfo_ModuleConfig proto.InternalMessageInfo + +func (m *ModuleConfig) GetName() string { + if m != nil { + return m.Name + } + return "" +} + +func (m *ModuleConfig) GetConfig() *any.Any { + if m != nil { + return m.Config + } + return nil +} + +func (m *ModuleConfig) GetGolangBindings() []*GolangBinding { + if m != nil { + return m.GolangBindings + } + return nil +} + +// GolangBinding is an explicit interface type to implementing type binding for dependency injection. +type GolangBinding struct { + // interface_type is the interface type which will be bound to a specific implementation type + InterfaceType string `protobuf:"bytes,1,opt,name=interface_type,json=interfaceType,proto3" json:"interface_type,omitempty"` + // implementation is the implementing type which will be supplied when an input of type interface is requested + Implementation string `protobuf:"bytes,2,opt,name=implementation,proto3" json:"implementation,omitempty"` +} + +func (m *GolangBinding) Reset() { *m = GolangBinding{} } +func (m *GolangBinding) String() string { return proto.CompactTextString(m) } +func (*GolangBinding) ProtoMessage() {} +func (*GolangBinding) Descriptor() ([]byte, []int) { + return fileDescriptor_5af1d229673256fa, []int{2} +} +func (m *GolangBinding) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *GolangBinding) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_GolangBinding.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *GolangBinding) XXX_Merge(src proto.Message) { + xxx_messageInfo_GolangBinding.Merge(m, src) +} +func (m *GolangBinding) XXX_Size() int { + return m.Size() +} +func (m *GolangBinding) XXX_DiscardUnknown() { + xxx_messageInfo_GolangBinding.DiscardUnknown(m) +} + +var xxx_messageInfo_GolangBinding proto.InternalMessageInfo + +func (m *GolangBinding) GetInterfaceType() string { + if m != nil { + return m.InterfaceType + } + return "" +} + +func (m *GolangBinding) GetImplementation() string { + if m != nil { + return m.Implementation + } + return "" +} + +func init() { + proto.RegisterType((*Config)(nil), "cosmos.app.v1alpha1.Config") + proto.RegisterType((*ModuleConfig)(nil), "cosmos.app.v1alpha1.ModuleConfig") + proto.RegisterType((*GolangBinding)(nil), "cosmos.app.v1alpha1.GolangBinding") +} + +func init() { proto.RegisterFile("cosmos/app/v1alpha1/config.proto", fileDescriptor_5af1d229673256fa) } + +var fileDescriptor_5af1d229673256fa = []byte{ + // 333 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x92, 0x31, 0x4f, 0x02, 0x31, + 0x1c, 0xc5, 0x29, 0x18, 0x0c, 0x45, 0x30, 0xa9, 0x0e, 0xa7, 0xc3, 0xe5, 0x24, 0xd1, 0x60, 0x62, + 0xda, 0x80, 0xa3, 0x93, 0x30, 0x38, 0x18, 0x97, 0x8b, 0x93, 0x83, 0xa4, 0xdc, 0x95, 0x5a, 0xbd, + 0x6b, 0x1b, 0x5a, 0x4c, 0xee, 0x5b, 0x18, 0x77, 0xbf, 0x8f, 0x23, 0xa3, 0xa3, 0x81, 0x2f, 0x62, + 0x6c, 0x3d, 0x82, 0x86, 0xc9, 0xad, 0xfd, 0xe7, 0xf7, 0x7f, 0x7d, 0xaf, 0x79, 0x30, 0x4a, 0x94, + 0xc9, 0x95, 0x21, 0x54, 0x6b, 0xf2, 0xdc, 0xa3, 0x99, 0x7e, 0xa0, 0x3d, 0x92, 0x28, 0x39, 0x11, + 0x1c, 0xeb, 0xa9, 0xb2, 0x0a, 0xed, 0x79, 0x02, 0x53, 0xad, 0x71, 0x49, 0x1c, 0x1e, 0x70, 0xa5, + 0x78, 0xc6, 0x88, 0x43, 0xc6, 0xb3, 0x09, 0xa1, 0xb2, 0xf0, 0x7c, 0xe7, 0x15, 0xc0, 0xfa, 0xd0, + 0x09, 0xa0, 0x0b, 0xb8, 0x9d, 0xab, 0x74, 0x96, 0x31, 0x13, 0x80, 0xa8, 0xd6, 0x6d, 0xf6, 0x8f, + 0xf0, 0x06, 0x31, 0x7c, 0xe3, 0x18, 0xbf, 0x13, 0x97, 0x1b, 0xe8, 0x1a, 0xee, 0x72, 0x95, 0x51, + 0xc9, 0x47, 0x63, 0x21, 0x53, 0x21, 0xb9, 0x09, 0xaa, 0x4e, 0xa4, 0xb3, 0x51, 0xe4, 0xca, 0xb1, + 0x03, 0x8f, 0xc6, 0x6d, 0xbe, 0x7e, 0x35, 0x9d, 0x37, 0x00, 0x77, 0xd6, 0x9f, 0x41, 0x08, 0x6e, + 0x49, 0x9a, 0xb3, 0x00, 0x44, 0xa0, 0xdb, 0x88, 0xdd, 0x19, 0x9d, 0xc1, 0xba, 0x4f, 0x1e, 0x54, + 0x23, 0xd0, 0x6d, 0xf6, 0xf7, 0xb1, 0x4f, 0x89, 0xcb, 0x94, 0xf8, 0x52, 0x16, 0xf1, 0x0f, 0xb3, + 0xc9, 0x5f, 0xed, 0xdf, 0xfe, 0xee, 0x61, 0xeb, 0x17, 0x80, 0x8e, 0x61, 0x5b, 0x48, 0xcb, 0xa6, + 0x13, 0x9a, 0xb0, 0x91, 0x2d, 0x74, 0xe9, 0xb4, 0xb5, 0x9a, 0xde, 0x16, 0x9a, 0xa1, 0x13, 0xd8, + 0x16, 0xb9, 0xce, 0x58, 0xce, 0xa4, 0xa5, 0x56, 0x28, 0xe9, 0xac, 0x37, 0xe2, 0x3f, 0xd3, 0xc1, + 0xf0, 0x7d, 0x11, 0x82, 0xf9, 0x22, 0x04, 0x9f, 0x8b, 0x10, 0xbc, 0x2c, 0xc3, 0xca, 0x7c, 0x19, + 0x56, 0x3e, 0x96, 0x61, 0xe5, 0xee, 0xd4, 0x9b, 0x35, 0xe9, 0x13, 0x16, 0x8a, 0xa4, 0x4c, 0x0b, + 0xf9, 0xc8, 0x12, 0xfb, 0x5d, 0x08, 0x1f, 0x74, 0x55, 0x8b, 0x71, 0xdd, 0xfd, 0xc3, 0xf9, 0x57, + 0x00, 0x00, 0x00, 0xff, 0xff, 0xd5, 0xfa, 0x9f, 0xcf, 0x34, 0x02, 0x00, 0x00, +} + +func (m *Config) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *Config) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Config) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.GolangBindings) > 0 { + for iNdEx := len(m.GolangBindings) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.GolangBindings[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintConfig(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + } + if len(m.Modules) > 0 { + for iNdEx := len(m.Modules) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Modules[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintConfig(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func (m *ModuleConfig) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *ModuleConfig) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *ModuleConfig) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.GolangBindings) > 0 { + for iNdEx := len(m.GolangBindings) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.GolangBindings[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintConfig(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + } + } + if m.Config != nil { + { + size, err := m.Config.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintConfig(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if len(m.Name) > 0 { + i -= len(m.Name) + copy(dAtA[i:], m.Name) + i = encodeVarintConfig(dAtA, i, uint64(len(m.Name))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *GolangBinding) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *GolangBinding) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *GolangBinding) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Implementation) > 0 { + i -= len(m.Implementation) + copy(dAtA[i:], m.Implementation) + i = encodeVarintConfig(dAtA, i, uint64(len(m.Implementation))) + i-- + dAtA[i] = 0x12 + } + if len(m.InterfaceType) > 0 { + i -= len(m.InterfaceType) + copy(dAtA[i:], m.InterfaceType) + i = encodeVarintConfig(dAtA, i, uint64(len(m.InterfaceType))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintConfig(dAtA []byte, offset int, v uint64) int { + offset -= sovConfig(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *Config) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Modules) > 0 { + for _, e := range m.Modules { + l = e.Size() + n += 1 + l + sovConfig(uint64(l)) + } + } + if len(m.GolangBindings) > 0 { + for _, e := range m.GolangBindings { + l = e.Size() + n += 1 + l + sovConfig(uint64(l)) + } + } + return n +} + +func (m *ModuleConfig) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Name) + if l > 0 { + n += 1 + l + sovConfig(uint64(l)) + } + if m.Config != nil { + l = m.Config.Size() + n += 1 + l + sovConfig(uint64(l)) + } + if len(m.GolangBindings) > 0 { + for _, e := range m.GolangBindings { + l = e.Size() + n += 1 + l + sovConfig(uint64(l)) + } + } + return n +} + +func (m *GolangBinding) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.InterfaceType) + if l > 0 { + n += 1 + l + sovConfig(uint64(l)) + } + l = len(m.Implementation) + if l > 0 { + n += 1 + l + sovConfig(uint64(l)) + } + return n +} + +func sovConfig(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozConfig(x uint64) (n int) { + return sovConfig(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *Config) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowConfig + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: Config: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Config: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Modules", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowConfig + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthConfig + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthConfig + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Modules = append(m.Modules, &ModuleConfig{}) + if err := m.Modules[len(m.Modules)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field GolangBindings", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowConfig + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthConfig + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthConfig + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.GolangBindings = append(m.GolangBindings, &GolangBinding{}) + if err := m.GolangBindings[len(m.GolangBindings)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipConfig(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthConfig + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *ModuleConfig) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowConfig + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: ModuleConfig: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ModuleConfig: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Name", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowConfig + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthConfig + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthConfig + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Name = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Config", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowConfig + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthConfig + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthConfig + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Config == nil { + m.Config = &any.Any{} + } + if err := m.Config.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field GolangBindings", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowConfig + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthConfig + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthConfig + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.GolangBindings = append(m.GolangBindings, &GolangBinding{}) + if err := m.GolangBindings[len(m.GolangBindings)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipConfig(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthConfig + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *GolangBinding) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowConfig + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: GolangBinding: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: GolangBinding: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field InterfaceType", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowConfig + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthConfig + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthConfig + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.InterfaceType = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Implementation", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowConfig + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthConfig + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthConfig + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Implementation = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipConfig(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthConfig + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipConfig(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowConfig + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowConfig + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowConfig + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthConfig + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupConfig + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthConfig + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthConfig = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowConfig = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupConfig = fmt.Errorf("proto: unexpected end of group") +) diff --git a/depinject/appconfig/v1alpha1/module.pb.go b/depinject/appconfig/v1alpha1/module.pb.go new file mode 100644 index 000000000000..67dde820c1ec --- /dev/null +++ b/depinject/appconfig/v1alpha1/module.pb.go @@ -0,0 +1,893 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: cosmos/app/v1alpha1/module.proto + +package v1alpha1 + +import ( + fmt "fmt" + proto "github.com/cosmos/gogoproto/proto" + descriptorpb "google.golang.org/protobuf/types/descriptorpb" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// ModuleDescriptor describes an app module. +type ModuleDescriptor struct { + // go_import names the package that should be imported by an app to load the + // module in the runtime module registry. It is required to make debugging + // of configuration errors easier for users. + GoImport string `protobuf:"bytes,1,opt,name=go_import,json=goImport,proto3" json:"go_import,omitempty"` + // use_package refers to a protobuf package that this module + // uses and exposes to the world. In an app, only one module should "use" + // or own a single protobuf package. It is assumed that the module uses + // all of the .proto files in a single package. + UsePackage []*PackageReference `protobuf:"bytes,2,rep,name=use_package,json=usePackage,proto3" json:"use_package,omitempty"` + // can_migrate_from defines which module versions this module can migrate + // state from. The framework will check that one module version is able to + // migrate from a previous module version before attempting to update its + // config. It is assumed that modules can transitively migrate from earlier + // versions. For instance if v3 declares it can migrate from v2, and v2 + // declares it can migrate from v1, the framework knows how to migrate + // from v1 to v3, assuming all 3 module versions are registered at runtime. + CanMigrateFrom []*MigrateFromInfo `protobuf:"bytes,3,rep,name=can_migrate_from,json=canMigrateFrom,proto3" json:"can_migrate_from,omitempty"` +} + +func (m *ModuleDescriptor) Reset() { *m = ModuleDescriptor{} } +func (m *ModuleDescriptor) String() string { return proto.CompactTextString(m) } +func (*ModuleDescriptor) ProtoMessage() {} +func (*ModuleDescriptor) Descriptor() ([]byte, []int) { + return fileDescriptor_0e7eb8b9b8dcd164, []int{0} +} +func (m *ModuleDescriptor) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *ModuleDescriptor) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_ModuleDescriptor.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *ModuleDescriptor) XXX_Merge(src proto.Message) { + xxx_messageInfo_ModuleDescriptor.Merge(m, src) +} +func (m *ModuleDescriptor) XXX_Size() int { + return m.Size() +} +func (m *ModuleDescriptor) XXX_DiscardUnknown() { + xxx_messageInfo_ModuleDescriptor.DiscardUnknown(m) +} + +var xxx_messageInfo_ModuleDescriptor proto.InternalMessageInfo + +func (m *ModuleDescriptor) GetGoImport() string { + if m != nil { + return m.GoImport + } + return "" +} + +func (m *ModuleDescriptor) GetUsePackage() []*PackageReference { + if m != nil { + return m.UsePackage + } + return nil +} + +func (m *ModuleDescriptor) GetCanMigrateFrom() []*MigrateFromInfo { + if m != nil { + return m.CanMigrateFrom + } + return nil +} + +// PackageReference is a reference to a protobuf package used by a module. +type PackageReference struct { + // name is the fully-qualified name of the package. + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` + // revision is the optional revision of the package that is being used. + // Protobuf packages used in Cosmos should generally have a major version + // as the last part of the package name, ex. foo.bar.baz.v1. + // The revision of a package can be thought of as the minor version of a + // package which has additional backwards compatible definitions that weren't + // present in a previous version. + // + // A package should indicate its revision with a source code comment + // above the package declaration in one of its files containing the + // text "Revision N" where N is an integer revision. All packages start + // at revision 0 the first time they are released in a module. + // + // When a new version of a module is released and items are added to existing + // .proto files, these definitions should contain comments of the form + // "Since: Revision N" where N is an integer revision. + // + // When the module runtime starts up, it will check the pinned proto + // image and panic if there are runtime protobuf definitions that are not + // in the pinned descriptor which do not have + // a "Since Revision N" comment or have a "Since Revision N" comment where + // N is <= to the revision specified here. This indicates that the protobuf + // files have been updated, but the pinned file descriptor hasn't. + // + // If there are items in the pinned file descriptor with a revision + // greater than the value indicated here, this will also cause a panic + // as it may mean that the pinned descriptor for a legacy module has been + // improperly updated or that there is some other versioning discrepancy. + // Runtime protobuf definitions will also be checked for compatibility + // with pinned file descriptors to make sure there are no incompatible changes. + // + // This behavior ensures that: + // - pinned proto images are up-to-date + // - protobuf files are carefully annotated with revision comments which + // are important good client UX + // - protobuf files are changed in backwards and forwards compatible ways + Revision uint32 `protobuf:"varint,2,opt,name=revision,proto3" json:"revision,omitempty"` +} + +func (m *PackageReference) Reset() { *m = PackageReference{} } +func (m *PackageReference) String() string { return proto.CompactTextString(m) } +func (*PackageReference) ProtoMessage() {} +func (*PackageReference) Descriptor() ([]byte, []int) { + return fileDescriptor_0e7eb8b9b8dcd164, []int{1} +} +func (m *PackageReference) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *PackageReference) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_PackageReference.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *PackageReference) XXX_Merge(src proto.Message) { + xxx_messageInfo_PackageReference.Merge(m, src) +} +func (m *PackageReference) XXX_Size() int { + return m.Size() +} +func (m *PackageReference) XXX_DiscardUnknown() { + xxx_messageInfo_PackageReference.DiscardUnknown(m) +} + +var xxx_messageInfo_PackageReference proto.InternalMessageInfo + +func (m *PackageReference) GetName() string { + if m != nil { + return m.Name + } + return "" +} + +func (m *PackageReference) GetRevision() uint32 { + if m != nil { + return m.Revision + } + return 0 +} + +// MigrateFromInfo is information on a module version that a newer module +// can migrate from. +type MigrateFromInfo struct { + // module is the fully-qualified protobuf name of the module config object + // for the previous module version, ex: "cosmos.group.module.v1.Module". + Module string `protobuf:"bytes,1,opt,name=module,proto3" json:"module,omitempty"` +} + +func (m *MigrateFromInfo) Reset() { *m = MigrateFromInfo{} } +func (m *MigrateFromInfo) String() string { return proto.CompactTextString(m) } +func (*MigrateFromInfo) ProtoMessage() {} +func (*MigrateFromInfo) Descriptor() ([]byte, []int) { + return fileDescriptor_0e7eb8b9b8dcd164, []int{2} +} +func (m *MigrateFromInfo) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MigrateFromInfo) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MigrateFromInfo.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *MigrateFromInfo) XXX_Merge(src proto.Message) { + xxx_messageInfo_MigrateFromInfo.Merge(m, src) +} +func (m *MigrateFromInfo) XXX_Size() int { + return m.Size() +} +func (m *MigrateFromInfo) XXX_DiscardUnknown() { + xxx_messageInfo_MigrateFromInfo.DiscardUnknown(m) +} + +var xxx_messageInfo_MigrateFromInfo proto.InternalMessageInfo + +func (m *MigrateFromInfo) GetModule() string { + if m != nil { + return m.Module + } + return "" +} + +var E_Module = &proto.ExtensionDesc{ + ExtendedType: (*descriptorpb.MessageOptions)(nil), + ExtensionType: (*ModuleDescriptor)(nil), + Field: 57193479, + Name: "cosmos.app.v1alpha1.module", + Tag: "bytes,57193479,opt,name=module", + Filename: "cosmos/app/v1alpha1/module.proto", +} + +func init() { + proto.RegisterType((*ModuleDescriptor)(nil), "cosmos.app.v1alpha1.ModuleDescriptor") + proto.RegisterType((*PackageReference)(nil), "cosmos.app.v1alpha1.PackageReference") + proto.RegisterType((*MigrateFromInfo)(nil), "cosmos.app.v1alpha1.MigrateFromInfo") + proto.RegisterExtension(E_Module) +} + +func init() { proto.RegisterFile("cosmos/app/v1alpha1/module.proto", fileDescriptor_0e7eb8b9b8dcd164) } + +var fileDescriptor_0e7eb8b9b8dcd164 = []byte{ + // 368 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0x52, 0xcd, 0xaa, 0x13, 0x31, + 0x18, 0x6d, 0xee, 0x95, 0xcb, 0x6d, 0x8a, 0x5a, 0x22, 0xc8, 0xd0, 0xc2, 0x38, 0x14, 0x85, 0x76, + 0x93, 0xa1, 0xba, 0x73, 0x59, 0xa5, 0xd0, 0x45, 0x55, 0x66, 0xe9, 0x66, 0x48, 0x33, 0xdf, 0xc4, + 0xd8, 0x4e, 0xbe, 0x90, 0xcc, 0xf4, 0x15, 0xdc, 0xfa, 0x0c, 0xbe, 0x8c, 0x2e, 0xbb, 0x74, 0x29, + 0xed, 0xc6, 0xc7, 0x10, 0xe7, 0xa7, 0x48, 0xa9, 0xbb, 0x9c, 0x93, 0x93, 0x73, 0xf2, 0x1d, 0x3e, + 0x1a, 0x49, 0xf4, 0x05, 0xfa, 0x58, 0x58, 0x1b, 0xef, 0xe7, 0x62, 0x67, 0x3f, 0x89, 0x79, 0x5c, + 0x60, 0x56, 0xed, 0x80, 0x5b, 0x87, 0x25, 0xb2, 0x27, 0x8d, 0x82, 0x0b, 0x6b, 0x79, 0xa7, 0x18, + 0x45, 0x0a, 0x51, 0xed, 0x20, 0xae, 0x25, 0x9b, 0x2a, 0x8f, 0x33, 0xf0, 0xd2, 0x69, 0x5b, 0xa2, + 0x6b, 0x9e, 0x4d, 0xbe, 0x13, 0x3a, 0x5c, 0xd7, 0x3e, 0x6f, 0xcf, 0x57, 0x6c, 0x4c, 0xfb, 0x0a, + 0x53, 0x5d, 0x58, 0x74, 0x65, 0x40, 0x22, 0x32, 0xed, 0x27, 0xf7, 0x0a, 0x57, 0x35, 0x66, 0x4b, + 0x3a, 0xa8, 0x3c, 0xa4, 0x56, 0xc8, 0xad, 0x50, 0x10, 0xdc, 0x44, 0xb7, 0xd3, 0xc1, 0xcb, 0x17, + 0xfc, 0x4a, 0x3c, 0xff, 0xd0, 0x68, 0x12, 0xc8, 0xc1, 0x81, 0x91, 0x90, 0xd0, 0xca, 0x43, 0x4b, + 0xb2, 0x77, 0x74, 0x28, 0x85, 0x49, 0x0b, 0xad, 0x9c, 0x28, 0x21, 0xcd, 0x1d, 0x16, 0xc1, 0x6d, + 0x6d, 0xf6, 0xfc, 0xaa, 0xd9, 0xba, 0x11, 0x2e, 0x1d, 0x16, 0x2b, 0x93, 0x63, 0xf2, 0x48, 0x0a, + 0xf3, 0x0f, 0x37, 0x59, 0xd0, 0xe1, 0x65, 0x1e, 0x63, 0xf4, 0x81, 0x11, 0x05, 0xb4, 0x33, 0xd4, + 0x67, 0x36, 0xa2, 0xf7, 0x0e, 0xf6, 0xda, 0x6b, 0x34, 0xc1, 0x4d, 0x44, 0xa6, 0x0f, 0x93, 0x33, + 0x9e, 0xcc, 0xe8, 0xe3, 0x8b, 0x18, 0xf6, 0x94, 0xde, 0x35, 0x3d, 0xb7, 0x26, 0x2d, 0x7a, 0x2d, + 0x3a, 0x9e, 0x3d, 0xe3, 0x4d, 0xcb, 0xbc, 0x6b, 0x99, 0xaf, 0xc1, 0x7b, 0xa1, 0xe0, 0xbd, 0x2d, + 0x35, 0x1a, 0x1f, 0x7c, 0xf9, 0xfd, 0x6d, 0x1c, 0x91, 0xff, 0xb6, 0x74, 0x59, 0x7f, 0x17, 0xb1, + 0x78, 0xf3, 0xe3, 0x18, 0x92, 0xc3, 0x31, 0x24, 0xbf, 0x8e, 0x21, 0xf9, 0x7a, 0x0a, 0x7b, 0x87, + 0x53, 0xd8, 0xfb, 0x79, 0x0a, 0x7b, 0x1f, 0x67, 0x8d, 0x8f, 0xcf, 0xb6, 0x5c, 0x63, 0x9c, 0x81, + 0xd5, 0xe6, 0x33, 0xc8, 0xf2, 0xef, 0x7a, 0x48, 0x34, 0xb9, 0x56, 0xe7, 0x25, 0xd9, 0xdc, 0xd5, + 0xbf, 0x7a, 0xf5, 0x27, 0x00, 0x00, 0xff, 0xff, 0xf5, 0x00, 0xca, 0xe6, 0x42, 0x02, 0x00, 0x00, +} + +func (m *ModuleDescriptor) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *ModuleDescriptor) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *ModuleDescriptor) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.CanMigrateFrom) > 0 { + for iNdEx := len(m.CanMigrateFrom) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.CanMigrateFrom[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintModule(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + } + } + if len(m.UsePackage) > 0 { + for iNdEx := len(m.UsePackage) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.UsePackage[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintModule(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + } + if len(m.GoImport) > 0 { + i -= len(m.GoImport) + copy(dAtA[i:], m.GoImport) + i = encodeVarintModule(dAtA, i, uint64(len(m.GoImport))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *PackageReference) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *PackageReference) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *PackageReference) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Revision != 0 { + i = encodeVarintModule(dAtA, i, uint64(m.Revision)) + i-- + dAtA[i] = 0x10 + } + if len(m.Name) > 0 { + i -= len(m.Name) + copy(dAtA[i:], m.Name) + i = encodeVarintModule(dAtA, i, uint64(len(m.Name))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MigrateFromInfo) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MigrateFromInfo) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MigrateFromInfo) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Module) > 0 { + i -= len(m.Module) + copy(dAtA[i:], m.Module) + i = encodeVarintModule(dAtA, i, uint64(len(m.Module))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintModule(dAtA []byte, offset int, v uint64) int { + offset -= sovModule(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *ModuleDescriptor) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.GoImport) + if l > 0 { + n += 1 + l + sovModule(uint64(l)) + } + if len(m.UsePackage) > 0 { + for _, e := range m.UsePackage { + l = e.Size() + n += 1 + l + sovModule(uint64(l)) + } + } + if len(m.CanMigrateFrom) > 0 { + for _, e := range m.CanMigrateFrom { + l = e.Size() + n += 1 + l + sovModule(uint64(l)) + } + } + return n +} + +func (m *PackageReference) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Name) + if l > 0 { + n += 1 + l + sovModule(uint64(l)) + } + if m.Revision != 0 { + n += 1 + sovModule(uint64(m.Revision)) + } + return n +} + +func (m *MigrateFromInfo) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Module) + if l > 0 { + n += 1 + l + sovModule(uint64(l)) + } + return n +} + +func sovModule(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozModule(x uint64) (n int) { + return sovModule(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *ModuleDescriptor) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowModule + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: ModuleDescriptor: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ModuleDescriptor: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field GoImport", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowModule + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthModule + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthModule + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.GoImport = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field UsePackage", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowModule + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthModule + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthModule + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.UsePackage = append(m.UsePackage, &PackageReference{}) + if err := m.UsePackage[len(m.UsePackage)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field CanMigrateFrom", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowModule + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthModule + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthModule + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.CanMigrateFrom = append(m.CanMigrateFrom, &MigrateFromInfo{}) + if err := m.CanMigrateFrom[len(m.CanMigrateFrom)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipModule(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthModule + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *PackageReference) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowModule + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: PackageReference: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: PackageReference: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Name", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowModule + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthModule + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthModule + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Name = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Revision", wireType) + } + m.Revision = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowModule + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Revision |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipModule(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthModule + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MigrateFromInfo) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowModule + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MigrateFromInfo: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MigrateFromInfo: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Module", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowModule + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthModule + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthModule + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Module = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipModule(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthModule + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipModule(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowModule + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowModule + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowModule + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthModule + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupModule + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthModule + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthModule = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowModule = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupModule = fmt.Errorf("proto: unexpected end of group") +) diff --git a/depinject/appconfig/v1alpha1/query.pb.go b/depinject/appconfig/v1alpha1/query.pb.go new file mode 100644 index 000000000000..363c61fa9cd8 --- /dev/null +++ b/depinject/appconfig/v1alpha1/query.pb.go @@ -0,0 +1,537 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: cosmos/app/v1alpha1/query.proto + +package v1alpha1 + +import ( + context "context" + fmt "fmt" + grpc1 "github.com/cosmos/gogoproto/grpc" + proto "github.com/cosmos/gogoproto/proto" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// QueryConfigRequest is the Query/Config request type. +type QueryConfigRequest struct { +} + +func (m *QueryConfigRequest) Reset() { *m = QueryConfigRequest{} } +func (m *QueryConfigRequest) String() string { return proto.CompactTextString(m) } +func (*QueryConfigRequest) ProtoMessage() {} +func (*QueryConfigRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_bd84655af543ba53, []int{0} +} +func (m *QueryConfigRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryConfigRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryConfigRequest.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QueryConfigRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryConfigRequest.Merge(m, src) +} +func (m *QueryConfigRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryConfigRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryConfigRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryConfigRequest proto.InternalMessageInfo + +// QueryConfigResponse is the Query/Config response type. +type QueryConfigResponse struct { + // config is the current app config. + Config *Config `protobuf:"bytes,1,opt,name=config,proto3" json:"config,omitempty"` +} + +func (m *QueryConfigResponse) Reset() { *m = QueryConfigResponse{} } +func (m *QueryConfigResponse) String() string { return proto.CompactTextString(m) } +func (*QueryConfigResponse) ProtoMessage() {} +func (*QueryConfigResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_bd84655af543ba53, []int{1} +} +func (m *QueryConfigResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryConfigResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryConfigResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QueryConfigResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryConfigResponse.Merge(m, src) +} +func (m *QueryConfigResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryConfigResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryConfigResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryConfigResponse proto.InternalMessageInfo + +func (m *QueryConfigResponse) GetConfig() *Config { + if m != nil { + return m.Config + } + return nil +} + +func init() { + proto.RegisterType((*QueryConfigRequest)(nil), "cosmos.app.v1alpha1.QueryConfigRequest") + proto.RegisterType((*QueryConfigResponse)(nil), "cosmos.app.v1alpha1.QueryConfigResponse") +} + +func init() { proto.RegisterFile("cosmos/app/v1alpha1/query.proto", fileDescriptor_bd84655af543ba53) } + +var fileDescriptor_bd84655af543ba53 = []byte{ + // 222 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x4f, 0xce, 0x2f, 0xce, + 0xcd, 0x2f, 0xd6, 0x4f, 0x2c, 0x28, 0xd0, 0x2f, 0x33, 0x4c, 0xcc, 0x29, 0xc8, 0x48, 0x34, 0xd4, + 0x2f, 0x2c, 0x4d, 0x2d, 0xaa, 0xd4, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, 0x86, 0x28, 0xd0, + 0x4b, 0x2c, 0x28, 0xd0, 0x83, 0x29, 0x90, 0x52, 0xc0, 0xa6, 0x2b, 0x39, 0x3f, 0x2f, 0x2d, 0x33, + 0x1d, 0xa2, 0x4d, 0x49, 0x84, 0x4b, 0x28, 0x10, 0x64, 0x8a, 0x33, 0x58, 0x30, 0x28, 0xb5, 0xb0, + 0x34, 0xb5, 0xb8, 0x44, 0xc9, 0x8b, 0x4b, 0x18, 0x45, 0xb4, 0xb8, 0x20, 0x3f, 0xaf, 0x38, 0x55, + 0xc8, 0x98, 0x8b, 0x0d, 0xa2, 0x59, 0x82, 0x51, 0x81, 0x51, 0x83, 0xdb, 0x48, 0x5a, 0x0f, 0x8b, + 0xa5, 0x7a, 0x50, 0x4d, 0x50, 0xa5, 0x46, 0x99, 0x5c, 0xac, 0x60, 0xb3, 0x84, 0x12, 0xb8, 0xd8, + 0x20, 0x52, 0x42, 0xea, 0x58, 0xf5, 0x61, 0xba, 0x43, 0x4a, 0x83, 0xb0, 0x42, 0x88, 0xd3, 0x94, + 0x98, 0x3b, 0x98, 0x18, 0x9d, 0x9c, 0x4f, 0x3c, 0x92, 0x63, 0xbc, 0xf0, 0x48, 0x8e, 0xf1, 0xc1, + 0x23, 0x39, 0xc6, 0x09, 0x8f, 0xe5, 0x18, 0x2e, 0x3c, 0x96, 0x63, 0xb8, 0xf1, 0x58, 0x8e, 0x21, + 0x4a, 0x13, 0x62, 0x4e, 0x71, 0x4a, 0xb6, 0x5e, 0x66, 0xbe, 0x7e, 0x4a, 0x6a, 0x41, 0x66, 0x5e, + 0x56, 0x6a, 0x72, 0x09, 0x28, 0x60, 0x20, 0xce, 0x84, 0x07, 0x4f, 0x12, 0x1b, 0x38, 0x60, 0x8c, + 0x01, 0x01, 0x00, 0x00, 0xff, 0xff, 0x72, 0xe6, 0x07, 0x7f, 0x72, 0x01, 0x00, 0x00, +} + +// Reference imports to suppress errors if they are not otherwise used. +var _ context.Context +var _ grpc.ClientConn + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +const _ = grpc.SupportPackageIsVersion4 + +// QueryClient is the client API for Query service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type QueryClient interface { + // Config returns the current app config. + Config(ctx context.Context, in *QueryConfigRequest, opts ...grpc.CallOption) (*QueryConfigResponse, error) +} + +type queryClient struct { + cc grpc1.ClientConn +} + +func NewQueryClient(cc grpc1.ClientConn) QueryClient { + return &queryClient{cc} +} + +// Deprecated: Do not use. +func (c *queryClient) Config(ctx context.Context, in *QueryConfigRequest, opts ...grpc.CallOption) (*QueryConfigResponse, error) { + out := new(QueryConfigResponse) + err := c.cc.Invoke(ctx, "/cosmos.app.v1alpha1.Query/Config", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// QueryServer is the server API for Query service. +type QueryServer interface { + // Config returns the current app config. + Config(context.Context, *QueryConfigRequest) (*QueryConfigResponse, error) +} + +// UnimplementedQueryServer can be embedded to have forward compatible implementations. +type UnimplementedQueryServer struct { +} + +func (*UnimplementedQueryServer) Config(ctx context.Context, req *QueryConfigRequest) (*QueryConfigResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Config not implemented") +} + +func RegisterQueryServer(s grpc1.Server, srv QueryServer) { + s.RegisterService(&_Query_serviceDesc, srv) +} + +func _Query_Config_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryConfigRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).Config(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/cosmos.app.v1alpha1.Query/Config", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).Config(ctx, req.(*QueryConfigRequest)) + } + return interceptor(ctx, in, info, handler) +} + +var _Query_serviceDesc = grpc.ServiceDesc{ + ServiceName: "cosmos.app.v1alpha1.Query", + HandlerType: (*QueryServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "Config", + Handler: _Query_Config_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "cosmos/app/v1alpha1/query.proto", +} + +func (m *QueryConfigRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QueryConfigRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryConfigRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *QueryConfigResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QueryConfigResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryConfigResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Config != nil { + { + size, err := m.Config.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { + offset -= sovQuery(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *QueryConfigRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *QueryConfigResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Config != nil { + l = m.Config.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func sovQuery(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozQuery(x uint64) (n int) { + return sovQuery(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *QueryConfigRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryConfigRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryConfigRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryConfigResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryConfigResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryConfigResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Config", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Config == nil { + m.Config = &Config{} + } + if err := m.Config.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipQuery(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowQuery + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowQuery + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowQuery + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthQuery + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupQuery + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthQuery + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthQuery = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowQuery = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupQuery = fmt.Errorf("proto: unexpected end of group") +) diff --git a/depinject/go.mod b/depinject/go.mod index 83f43fb81cf3..086dbfc14784 100644 --- a/depinject/go.mod +++ b/depinject/go.mod @@ -3,11 +3,11 @@ module cosmossdk.io/depinject go 1.20 require ( - cosmossdk.io/api v0.7.5 github.com/cosmos/cosmos-proto v1.0.0-beta.5 github.com/cosmos/gogoproto v1.5.0 github.com/stretchr/testify v1.9.0 golang.org/x/exp v0.0.0-20231006140011-7918f672742d + google.golang.org/grpc v1.64.1 google.golang.org/protobuf v1.34.2 gotest.tools/v3 v3.5.1 sigs.k8s.io/yaml v1.4.0 @@ -19,11 +19,11 @@ require ( github.com/kr/pretty v0.3.1 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect github.com/rogpeppe/go-internal v1.11.0 // indirect + github.com/tendermint/go-amino v0.16.0 // indirect golang.org/x/net v0.27.0 // indirect golang.org/x/sys v0.22.0 // indirect golang.org/x/text v0.16.0 // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20240709173604-40e1e62336c5 // indirect - google.golang.org/grpc v1.64.1 // indirect gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/depinject/go.sum b/depinject/go.sum index d45197eef76f..aff372bf6fa8 100644 --- a/depinject/go.sum +++ b/depinject/go.sum @@ -1,16 +1,18 @@ -cosmossdk.io/api v0.7.5 h1:eMPTReoNmGUm8DeiQL9DyM8sYDjEhWzL1+nLbI9DqtQ= -cosmossdk.io/api v0.7.5/go.mod h1:IcxpYS5fMemZGqyYtErK7OqvdM0C8kdW3dq8Q/XIG38= github.com/cosmos/cosmos-proto v1.0.0-beta.5 h1:eNcayDLpip+zVLRLYafhzLvQlSmyab+RC5W7ZfmxJLA= github.com/cosmos/cosmos-proto v1.0.0-beta.5/go.mod h1:hQGLpiIUloJBMdQMMWb/4wRApmI9hjHH05nefC0Ojec= github.com/cosmos/gogoproto v1.5.0 h1:SDVwzEqZDDBoslaeZg+dGE55hdzHfgUA40pEanMh52o= github.com/cosmos/gogoproto v1.5.0/go.mod h1:iUM31aofn3ymidYG6bUR5ZFrk+Om8p5s754eMUcyp8I= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/golang/protobuf v1.3.0/go.mod h1:Qd/q+1AKNOZr9uGQzbzCmRO6sUih6GTPZv6a1/R87v0= github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= +github.com/google/gofuzz v0.0.0-20170612174753-24818f796faf/go.mod h1:HP5RmnzzSNb993RKQDq4+1A4ia9nllfqcQFTQJedwGI= +github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0= github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= @@ -24,16 +26,24 @@ github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZN github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs= github.com/rogpeppe/go-internal v1.11.0 h1:cWPaGQEPrBb5/AsnsZesgZZ9yb1OQ+GOISoDNXVBh4M= github.com/rogpeppe/go-internal v1.11.0/go.mod h1:ddIwULY96R17DhadqLgMfk9H9tvdUzkipdSkR5nkCZA= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= +github.com/tendermint/go-amino v0.16.0 h1:GyhmgQKvqF82e2oZeuMSp9JTN0N09emoSZlb2lyGa2E= +github.com/tendermint/go-amino v0.16.0/go.mod h1:TQU0M1i/ImAo+tYpZi73AU3V/dKeCoMC9Sphe2ZwGME= golang.org/x/exp v0.0.0-20231006140011-7918f672742d h1:jtJma62tbqLibJ5sFQz8bKtEM8rJBtfilJ2qTU199MI= golang.org/x/exp v0.0.0-20231006140011-7918f672742d/go.mod h1:ldy0pHrwJyGW56pPQzzkH36rKxoZW1tw7ZJpeKx+hdo= +golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.27.0 h1:5K3Njcw06/l2y9vpGCSdcxWOYHOUk3dVNGDXN+FvAys= golang.org/x/net v0.27.0/go.mod h1:dDi0PyhWNoiUOrAS8uXv/vnScO4wnHQO4mj9fn/RytE= +golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.22.0 h1:RI27ohtqKCnwULzJLqkv897zojh5/DwS/ENaMzUOaWI= golang.org/x/sys v0.22.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4= golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI= +google.golang.org/genproto v0.0.0-20180831171423-11092d34479b/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= google.golang.org/genproto/googleapis/rpc v0.0.0-20240709173604-40e1e62336c5 h1:SbSDUWW1PAO24TNpLdeheoYPd7kllICcLU52x6eD4kQ= google.golang.org/genproto/googleapis/rpc v0.0.0-20240709173604-40e1e62336c5/go.mod h1:Ue6ibwXGpU+dqIcODieyLOcgj7z8+IcskoNIgZxtrFY= google.golang.org/grpc v1.64.1 h1:LKtvyfbX3UGVPFcGqJ9ItpVWW6oN/2XqTxfAnwRRXiA= diff --git a/depinject/internal/appconfig/buf.gen.pulsar.yaml b/depinject/internal/appconfig/buf.gen.pulsar.yaml new file mode 100644 index 000000000000..1866261857af --- /dev/null +++ b/depinject/internal/appconfig/buf.gen.pulsar.yaml @@ -0,0 +1,5 @@ +version: v1 +plugins: + - name: go-pulsar + out: . + opt: paths=source_relative diff --git a/depinject/internal/appconfig/buf.gen.yaml b/depinject/internal/appconfig/buf.gen.yaml deleted file mode 100644 index 30a31e9678d3..000000000000 --- a/depinject/internal/appconfig/buf.gen.yaml +++ /dev/null @@ -1,11 +0,0 @@ -version: v1 -managed: - enabled: true - go_package_prefix: - default: cosmossdk.io/depinject/internal/appconfig - override: - buf.build/cosmos/cosmos-sdk: cosmossdk.io/api -plugins: - - name: go-pulsar - out: . - opt: paths=source_relative diff --git a/depinject/internal/appconfig/buf.yaml b/depinject/internal/appconfig/buf.yaml index ac1df238ebec..fffe6eb932cf 100644 --- a/depinject/internal/appconfig/buf.yaml +++ b/depinject/internal/appconfig/buf.yaml @@ -1,4 +1,6 @@ version: v1 +deps: + - buf.build/cosmos/cosmos-sdk lint: use: - DEFAULT diff --git a/depinject/internal/appconfig/registry.go b/depinject/internal/appconfig/registry.go index a03a3e859a43..87161353b66e 100644 --- a/depinject/internal/appconfig/registry.go +++ b/depinject/internal/appconfig/registry.go @@ -5,10 +5,13 @@ import ( "reflect" gogoproto "github.com/cosmos/gogoproto/proto" + "github.com/cosmos/gogoproto/protoc-gen-gogo/descriptor" + "google.golang.org/protobuf/encoding/protowire" protov2 "google.golang.org/protobuf/proto" + "google.golang.org/protobuf/reflect/protodesc" "google.golang.org/protobuf/reflect/protoreflect" - appv1alpha1 "cosmossdk.io/api/cosmos/app/v1alpha1" + "cosmossdk.io/depinject/appconfig/v1alpha1" ) // ModuleRegistry is the registry of module initializers indexed by their golang @@ -35,12 +38,16 @@ func ModulesByModuleTypeName() (map[string]*ModuleInitializer, error) { fullName := gogoproto.MessageName(initializer.ConfigProtoMessage) if desc, err := gogoproto.HybridResolver.FindDescriptorByName(protoreflect.FullName(fullName)); err == nil { - modDesc := protov2.GetExtension(desc.Options(), appv1alpha1.E_Module).(*appv1alpha1.ModuleDescriptor) + modDesc, err := GetModuleDescriptor(desc) + if err != nil { + return nil, err + } + if modDesc == nil { return nil, fmt.Errorf( "protobuf type %s registered as a module should have the option %s", - fullName, - appv1alpha1.E_Module.TypeDescriptor().FullName()) + desc.FullName(), + v1alpha1.E_Module.Name) } if modDesc.GoImport == "" { @@ -60,3 +67,47 @@ func ModulesByModuleTypeName() (map[string]*ModuleInitializer, error) { return res, nil } + +// GetModuleDescriptor returns the cosmos.app.v1alpha1.ModuleDescriptor or nil if one isn't found. +// Errors are returned in unexpected cases. +func GetModuleDescriptor(desc protoreflect.Descriptor) (*v1alpha1.ModuleDescriptor, error) { + // we need to take a somewhat round about way to get the extension here + // our most complete type registry has a mix of gogoproto and protoreflect types + // so we start with a protoreflect descriptor, convert it to a gogo descriptor + // and then get the extension by its raw field value to avoid any unmarshaling errors + + rawV2Desc := protodesc.ToDescriptorProto(desc.(protoreflect.MessageDescriptor)) + bz, err := protov2.Marshal(rawV2Desc) + if err != nil { + return nil, err + } + var gogoDesc descriptor.DescriptorProto + err = gogoproto.Unmarshal(bz, &gogoDesc) + if err != nil { + return nil, err + } + + opts := gogoDesc.Options + if !gogoproto.HasExtension(opts, v1alpha1.E_Module) { + return nil, nil + } + + bz, err = gogoproto.GetRawExtension(gogoproto.GetUnsafeExtensionsMap(opts), v1alpha1.E_Module.Field) + if err != nil { + return nil, err + } + + // we have to skip the field tag and length prefix itself to actually get the raw bytes we want + // this is really overly complex, but other methods caused runtime errors because of validation + // that gogo does that appears simply not necessary + _, _, n := protowire.ConsumeTag(bz) + bz, _ = protowire.ConsumeBytes(bz[n:]) + + var ext v1alpha1.ModuleDescriptor + err = gogoproto.Unmarshal(bz, &ext) + if err != nil { + return nil, err + } + + return &ext, nil +} diff --git a/depinject/internal/appconfig/testpb/test.proto b/depinject/internal/appconfig/testpb/test.proto index fe6535a2d44a..ac1a8939e0ec 100644 --- a/depinject/internal/appconfig/testpb/test.proto +++ b/depinject/internal/appconfig/testpb/test.proto @@ -4,6 +4,8 @@ package testpb; import "cosmos/app/v1alpha1/module.proto"; +option go_package = "cosmossdk.io/depinject/internal/appconfig/testpb"; + message TestRuntimeModule { option (cosmos.app.v1alpha1.module) = { go_import: "cosmossdk.io/core/internal/testpb" diff --git a/depinject/internal/appconfig/testpb/test.pulsar.go b/depinject/internal/appconfig/testpb/test.pulsar.go index 90dcab61cc2b..2163a1fd6346 100644 --- a/depinject/internal/appconfig/testpb/test.pulsar.go +++ b/depinject/internal/appconfig/testpb/test.pulsar.go @@ -2,7 +2,7 @@ package testpb import ( - _ "cosmossdk.io/api/cosmos/app/v1alpha1" + _ "cosmossdk.io/depinject/appconfig/v1alpha1" fmt "fmt" runtime "github.com/cosmos/cosmos-proto/runtime" protoreflect "google.golang.org/protobuf/reflect/protoreflect" @@ -2344,14 +2344,10 @@ var file_testpb_test_proto_rawDesc = []byte{ 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x22, 0x1e, 0x0a, 0x14, 0x54, 0x65, 0x73, 0x74, 0x4e, 0x6f, 0x47, 0x6f, 0x49, 0x6d, 0x70, 0x6f, 0x72, 0x74, 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x3a, 0x06, 0xba, 0xc0, 0x96, 0xda, - 0x01, 0x00, 0x42, 0x72, 0x0a, 0x0a, 0x63, 0x6f, 0x6d, 0x2e, 0x74, 0x65, 0x73, 0x74, 0x70, 0x62, - 0x42, 0x09, 0x54, 0x65, 0x73, 0x74, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x21, 0x63, - 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x63, 0x6f, 0x72, 0x65, - 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x74, 0x65, 0x73, 0x74, 0x70, 0x62, - 0xa2, 0x02, 0x03, 0x54, 0x58, 0x58, 0xaa, 0x02, 0x06, 0x54, 0x65, 0x73, 0x74, 0x70, 0x62, 0xca, - 0x02, 0x06, 0x54, 0x65, 0x73, 0x74, 0x70, 0x62, 0xe2, 0x02, 0x12, 0x54, 0x65, 0x73, 0x74, 0x70, - 0x62, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x06, - 0x54, 0x65, 0x73, 0x74, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x01, 0x00, 0x42, 0x32, 0x5a, 0x30, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, + 0x69, 0x6f, 0x2f, 0x64, 0x65, 0x70, 0x69, 0x6e, 0x6a, 0x65, 0x63, 0x74, 0x2f, 0x69, 0x6e, 0x74, + 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x61, 0x70, 0x70, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2f, + 0x74, 0x65, 0x73, 0x74, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/depinject/internal/appconfiggogo/buf.gen.gogo.yaml b/depinject/internal/appconfiggogo/buf.gen.gogo.yaml new file mode 100644 index 000000000000..ca01a181525f --- /dev/null +++ b/depinject/internal/appconfiggogo/buf.gen.gogo.yaml @@ -0,0 +1,5 @@ +version: v1 +plugins: + - name: gocosmos + out: . + opt: paths=source_relative diff --git a/depinject/internal/appconfiggogo/buf.gen.yaml b/depinject/internal/appconfiggogo/buf.gen.yaml deleted file mode 100644 index 48924f89b954..000000000000 --- a/depinject/internal/appconfiggogo/buf.gen.yaml +++ /dev/null @@ -1,11 +0,0 @@ -version: v1 -managed: - enabled: true - go_package_prefix: - default: cosmossdk.io/depinject/internal/appconfiggogo - override: - buf.build/cosmos/cosmos-sdk: cosmossdk.io/api -plugins: - - name: gocosmos - out: . - opt: paths=source_relative diff --git a/depinject/internal/appconfiggogo/buf.yaml b/depinject/internal/appconfiggogo/buf.yaml index ac1df238ebec..fffe6eb932cf 100644 --- a/depinject/internal/appconfiggogo/buf.yaml +++ b/depinject/internal/appconfiggogo/buf.yaml @@ -1,4 +1,6 @@ version: v1 +deps: + - buf.build/cosmos/cosmos-sdk lint: use: - DEFAULT diff --git a/depinject/internal/appconfiggogo/testpb/test.pb.go b/depinject/internal/appconfiggogo/testpb/test.pb.go index 583a24afe3eb..64cb974281db 100644 --- a/depinject/internal/appconfiggogo/testpb/test.pb.go +++ b/depinject/internal/appconfiggogo/testpb/test.pb.go @@ -4,7 +4,7 @@ package testpb import ( - _ "cosmossdk.io/api/cosmos/app/v1alpha1" + _ "cosmossdk.io/depinject/appconfig/v1alpha1" fmt "fmt" proto "github.com/cosmos/gogoproto/proto" io "io" @@ -66,22 +66,19 @@ func init() { func init() { proto.RegisterFile("testpb/test.proto", fileDescriptor_41c67e33ca9d1f26) } var fileDescriptor_41c67e33ca9d1f26 = []byte{ - // 240 bytes of a gzipped FileDescriptorProto + // 186 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x12, 0x2c, 0x49, 0x2d, 0x2e, 0x29, 0x48, 0xd2, 0x07, 0x51, 0x7a, 0x05, 0x45, 0xf9, 0x25, 0xf9, 0x42, 0x6c, 0x10, 0x21, 0x29, 0x85, 0xe4, 0xfc, 0xe2, 0xdc, 0xfc, 0x62, 0xfd, 0xc4, 0x82, 0x02, 0xfd, 0x32, 0xc3, 0xc4, 0x9c, - 0x82, 0x8c, 0x44, 0x43, 0xfd, 0xdc, 0xfc, 0x94, 0xd2, 0x9c, 0x54, 0x88, 0x4a, 0x25, 0x6b, 0x2e, - 0xbe, 0x90, 0xd4, 0xe2, 0x12, 0x5f, 0xb0, 0x98, 0x7b, 0x7e, 0x7a, 0xbe, 0x95, 0xe6, 0xae, 0x03, - 0xd3, 0x6e, 0x31, 0x2a, 0x73, 0x29, 0x42, 0xf4, 0x16, 0xa7, 0x64, 0xeb, 0x65, 0xe6, 0xeb, 0x27, - 0xe7, 0x17, 0xa5, 0xea, 0x67, 0xe6, 0x95, 0xa4, 0x16, 0xe5, 0x25, 0xe6, 0xe8, 0x43, 0x8c, 0x77, - 0x9a, 0xcb, 0x78, 0xe2, 0x91, 0x1c, 0xe3, 0x85, 0x47, 0x72, 0x8c, 0x0f, 0x1e, 0xc9, 0x31, 0x4e, - 0x78, 0x2c, 0xc7, 0x70, 0xe1, 0xb1, 0x1c, 0xc3, 0x8d, 0xc7, 0x72, 0x0c, 0x5c, 0x5c, 0xc9, 0xf9, - 0xb9, 0x7a, 0x50, 0x65, 0x9c, 0x20, 0x1b, 0x02, 0x40, 0xd6, 0x05, 0x30, 0x46, 0x99, 0xa0, 0x18, - 0x9b, 0x92, 0x5a, 0x90, 0x99, 0x97, 0x95, 0x9a, 0x5c, 0x82, 0x30, 0x3b, 0xb1, 0xa0, 0x20, 0x39, - 0x3f, 0x2f, 0x2d, 0x33, 0x3d, 0x3d, 0x3f, 0x3d, 0x1f, 0x6a, 0xd3, 0x22, 0x26, 0xe6, 0x90, 0x88, - 0x88, 0x55, 0x4c, 0x6c, 0x21, 0x60, 0xee, 0x29, 0x18, 0xe3, 0x11, 0x93, 0x10, 0x84, 0x11, 0xe3, - 0x1e, 0xe0, 0xe4, 0x9b, 0x5a, 0x92, 0x98, 0x92, 0x58, 0x92, 0xf8, 0x0a, 0x26, 0x9b, 0xc4, 0x06, - 0xf6, 0xa3, 0x31, 0x20, 0x00, 0x00, 0xff, 0xff, 0x2e, 0x9f, 0x4d, 0x9e, 0x22, 0x01, 0x00, 0x00, + 0x82, 0x8c, 0x44, 0x43, 0xfd, 0xdc, 0xfc, 0x94, 0xd2, 0x9c, 0x54, 0x88, 0x4a, 0x25, 0x4f, 0x2e, + 0xbe, 0x90, 0xd4, 0xe2, 0x12, 0x5f, 0xb0, 0x98, 0x7b, 0x7e, 0x7a, 0xbe, 0x95, 0xf9, 0xae, 0x03, + 0xd3, 0x6e, 0x31, 0x1a, 0x72, 0xe9, 0x43, 0xf4, 0x16, 0xa7, 0x64, 0xeb, 0x65, 0xe6, 0xeb, 0x27, + 0xe7, 0x17, 0xa5, 0xea, 0x67, 0xe6, 0x95, 0xa4, 0x16, 0xe5, 0x25, 0xe6, 0x80, 0xcc, 0x4b, 0xce, + 0xcf, 0x4b, 0xcb, 0x4c, 0x4f, 0xcf, 0x4f, 0xcf, 0xd7, 0x87, 0x58, 0xe6, 0xe4, 0x77, 0xe2, 0x91, + 0x1c, 0xe3, 0x85, 0x47, 0x72, 0x8c, 0x0f, 0x1e, 0xc9, 0x31, 0x4e, 0x78, 0x2c, 0xc7, 0x70, 0xe1, + 0xb1, 0x1c, 0xc3, 0x8d, 0xc7, 0x72, 0x0c, 0x51, 0x26, 0x28, 0x46, 0xa5, 0xa4, 0x16, 0x64, 0xe6, + 0x65, 0xa5, 0x26, 0x97, 0xe0, 0x37, 0x2f, 0x89, 0x0d, 0xec, 0x42, 0x63, 0x40, 0x00, 0x00, 0x00, + 0xff, 0xff, 0x1e, 0xdb, 0x22, 0xe2, 0xe0, 0x00, 0x00, 0x00, } func (m *TestModuleGogo) Marshal() (dAtA []byte, err error) { diff --git a/depinject/internal/appconfiggogo/testpb/test.proto b/depinject/internal/appconfiggogo/testpb/test.proto index 47294a53b476..4b2154571d2e 100644 --- a/depinject/internal/appconfiggogo/testpb/test.proto +++ b/depinject/internal/appconfiggogo/testpb/test.proto @@ -4,6 +4,8 @@ package testpb; import "cosmos/app/v1alpha1/module.proto"; +option go_package = "cosmossdk.io/depinject/internal/appconfiggogo/testpb"; + message TestModuleGogo { option (cosmos.app.v1alpha1.module) = { go_import: "cosmossdk.io/core/internal/appconfiggogo/testpb" diff --git a/orm/go.mod b/orm/go.mod index 6d94ca592acf..86c7619af94c 100644 --- a/orm/go.mod +++ b/orm/go.mod @@ -58,6 +58,7 @@ require ( github.com/rogpeppe/go-internal v1.12.0 // indirect github.com/spf13/cast v1.6.0 // indirect github.com/syndtr/goleveldb v1.0.1-0.20220721030215-126854af5e6d // indirect + github.com/tendermint/go-amino v0.16.0 // indirect golang.org/x/net v0.27.0 // indirect golang.org/x/sys v0.22.0 // indirect golang.org/x/text v0.16.0 // indirect diff --git a/orm/go.sum b/orm/go.sum index b7d78aa2e5aa..ace3ac645255 100644 --- a/orm/go.sum +++ b/orm/go.sum @@ -63,6 +63,7 @@ github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69 github.com/golang/mock v1.6.0 h1:ErTB+efbowRARo13NNdxyJji2egdxLGQhRaY+DUumQc= github.com/golang/mock v1.6.0/go.mod h1:p6yTPP+5HYm5mzsMV8JkE6ZKdX+/wYM6Hr+LicevLPs= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.3.0/go.mod h1:Qd/q+1AKNOZr9uGQzbzCmRO6sUih6GTPZv6a1/R87v0= github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8= github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA= github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs= @@ -84,6 +85,9 @@ github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/ github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= +github.com/google/gofuzz v0.0.0-20170612174753-24818f796faf/go.mod h1:HP5RmnzzSNb993RKQDq4+1A4ia9nllfqcQFTQJedwGI= +github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0= +github.com/google/gofuzz v1.2.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= github.com/iancoleman/strcase v0.3.0 h1:nTXanmYxhfFAMjZL34Ov6gkzEsSJZ5DbhxWjvSASxEI= @@ -141,12 +145,15 @@ github.com/rogpeppe/go-internal v1.12.0/go.mod h1:E+RYuTGaKKdloAfM02xzb0FW3Paa99 github.com/spf13/cast v1.6.0 h1:GEiTHELF+vaR5dhz3VqZfFSzZjYbgeKDpBxQVS4GYJ0= github.com/spf13/cast v1.6.0/go.mod h1:ancEpBxwJDODSW/UG4rDrAqiKolqNNh2DX3mk86cAdo= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= github.com/stretchr/testify v1.7.2/go.mod h1:R6va5+xMeoiuVRoj+gSkQ7d3FALtqAAGI1FQKckRals= github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/syndtr/goleveldb v1.0.1-0.20220721030215-126854af5e6d h1:vfofYNRScrDdvS342BElfbETmL1Aiz3i2t0zfRj16Hs= github.com/syndtr/goleveldb v1.0.1-0.20220721030215-126854af5e6d/go.mod h1:RRCYJbIwD5jmqPI9XoAFR0OcDxqUctll6zUj/+B4S48= +github.com/tendermint/go-amino v0.16.0 h1:GyhmgQKvqF82e2oZeuMSp9JTN0N09emoSZlb2lyGa2E= +github.com/tendermint/go-amino v0.16.0/go.mod h1:TQU0M1i/ImAo+tYpZi73AU3V/dKeCoMC9Sphe2ZwGME= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= @@ -171,6 +178,7 @@ golang.org/x/net v0.0.0-20220607020251-c690dde0001d/go.mod h1:XRhObCWvk6IyKnWLug golang.org/x/net v0.27.0 h1:5K3Njcw06/l2y9vpGCSdcxWOYHOUk3dVNGDXN+FvAys= golang.org/x/net v0.27.0/go.mod h1:dDi0PyhWNoiUOrAS8uXv/vnScO4wnHQO4mj9fn/RytE= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -217,6 +225,7 @@ golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8T golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20220517211312-f3a8303e98df/go.mod h1:K8+ghG5WaK9qNqU5K3HdILfMLy1f3aNYFI/wnl100a8= +google.golang.org/genproto v0.0.0-20180831171423-11092d34479b/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= google.golang.org/genproto/googleapis/api v0.0.0-20240318140521-94a12d6c2237 h1:RFiFrvy37/mpSpdySBDrUdipW/dHwsRwh3J3+A9VgT4= google.golang.org/genproto/googleapis/api v0.0.0-20240318140521-94a12d6c2237/go.mod h1:Z5Iiy3jtmioajWHDGFk7CeugTyHtPvMHA4UTmUkyalE= google.golang.org/genproto/googleapis/rpc v0.0.0-20240709173604-40e1e62336c5 h1:SbSDUWW1PAO24TNpLdeheoYPd7kllICcLU52x6eD4kQ= diff --git a/proto/cosmos/app/v1alpha1/config.proto b/proto/cosmos/app/v1alpha1/config.proto index f1993b82c134..1aac4b4396f5 100644 --- a/proto/cosmos/app/v1alpha1/config.proto +++ b/proto/cosmos/app/v1alpha1/config.proto @@ -4,7 +4,7 @@ package cosmos.app.v1alpha1; import "google/protobuf/any.proto"; -option go_package = "cosmossdk.io/api/app/v1alpha1"; +option go_package = "cosmossdk.io/depinject/appconfig/v1alpha1"; // Config represents the configuration for a Cosmos SDK ABCI app. // It is intended that all state machine logic including the version of diff --git a/proto/cosmos/app/v1alpha1/module.proto b/proto/cosmos/app/v1alpha1/module.proto index 823dcb7d3259..ea475f35e17e 100644 --- a/proto/cosmos/app/v1alpha1/module.proto +++ b/proto/cosmos/app/v1alpha1/module.proto @@ -4,7 +4,7 @@ package cosmos.app.v1alpha1; import "google/protobuf/descriptor.proto"; -option go_package = "cosmossdk.io/api/app/v1alpha1"; +option go_package = "cosmossdk.io/depinject/appconfig/v1alpha1"; extend google.protobuf.MessageOptions { // module indicates that this proto type is a config object for an app module diff --git a/proto/cosmos/app/v1alpha1/query.proto b/proto/cosmos/app/v1alpha1/query.proto index 2a854b18b259..a51aea691db8 100644 --- a/proto/cosmos/app/v1alpha1/query.proto +++ b/proto/cosmos/app/v1alpha1/query.proto @@ -4,7 +4,7 @@ package cosmos.app.v1alpha1; import "cosmos/app/v1alpha1/config.proto"; -option go_package = "cosmossdk.io/api/app/v1alpha1"; +option go_package = "cosmossdk.io/depinject/appconfig/v1alpha1"; // Query is the app module query service. service Query { diff --git a/runtime/v2/go.mod b/runtime/v2/go.mod index 48af66777b16..3873280d2b38 100644 --- a/runtime/v2/go.mod +++ b/runtime/v2/go.mod @@ -84,6 +84,7 @@ require ( github.com/spf13/cast v1.6.0 // indirect github.com/stretchr/testify v1.9.0 // indirect github.com/syndtr/goleveldb v1.0.1-0.20220721030215-126854af5e6d // indirect + github.com/tendermint/go-amino v0.16.0 // indirect github.com/tidwall/btree v1.7.0 // indirect golang.org/x/crypto v0.25.0 // indirect golang.org/x/net v0.27.0 // indirect diff --git a/runtime/v2/go.sum b/runtime/v2/go.sum index 5ffc4256a190..069bd8c96bf4 100644 --- a/runtime/v2/go.sum +++ b/runtime/v2/go.sum @@ -77,6 +77,7 @@ github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69 github.com/golang/mock v1.6.0 h1:ErTB+efbowRARo13NNdxyJji2egdxLGQhRaY+DUumQc= github.com/golang/mock v1.6.0/go.mod h1:p6yTPP+5HYm5mzsMV8JkE6ZKdX+/wYM6Hr+LicevLPs= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.3.0/go.mod h1:Qd/q+1AKNOZr9uGQzbzCmRO6sUih6GTPZv6a1/R87v0= github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8= @@ -100,7 +101,10 @@ github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/ github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= +github.com/google/gofuzz v0.0.0-20170612174753-24818f796faf/go.mod h1:HP5RmnzzSNb993RKQDq4+1A4ia9nllfqcQFTQJedwGI= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= +github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0= +github.com/google/gofuzz v1.2.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= github.com/hashicorp/go-cleanhttp v0.5.0/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= github.com/hashicorp/go-immutable-radix v1.0.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60= @@ -218,6 +222,8 @@ github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsT github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/syndtr/goleveldb v1.0.1-0.20220721030215-126854af5e6d h1:vfofYNRScrDdvS342BElfbETmL1Aiz3i2t0zfRj16Hs= github.com/syndtr/goleveldb v1.0.1-0.20220721030215-126854af5e6d/go.mod h1:RRCYJbIwD5jmqPI9XoAFR0OcDxqUctll6zUj/+B4S48= +github.com/tendermint/go-amino v0.16.0 h1:GyhmgQKvqF82e2oZeuMSp9JTN0N09emoSZlb2lyGa2E= +github.com/tendermint/go-amino v0.16.0/go.mod h1:TQU0M1i/ImAo+tYpZi73AU3V/dKeCoMC9Sphe2ZwGME= github.com/tidwall/btree v1.7.0 h1:L1fkJH/AuEh5zBnnBbmTwQ5Lt+bRJ5A8EWecslvo9iI= github.com/tidwall/btree v1.7.0/go.mod h1:twD9XRA5jj9VUQGELzDO4HPQTNJsoWWfYEL+EUQ2cKY= github.com/tv42/httpunix v0.0.0-20150427012821-b75d8614f926/go.mod h1:9ESjWnEqriFuLhtthL60Sar/7RFoluCcXsuvEwTV5KM= @@ -249,6 +255,7 @@ golang.org/x/net v0.27.0/go.mod h1:dDi0PyhWNoiUOrAS8uXv/vnScO4wnHQO4mj9fn/RytE= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -297,6 +304,7 @@ golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8T golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20220517211312-f3a8303e98df/go.mod h1:K8+ghG5WaK9qNqU5K3HdILfMLy1f3aNYFI/wnl100a8= +google.golang.org/genproto v0.0.0-20180831171423-11092d34479b/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= google.golang.org/genproto/googleapis/api v0.0.0-20240318140521-94a12d6c2237 h1:RFiFrvy37/mpSpdySBDrUdipW/dHwsRwh3J3+A9VgT4= google.golang.org/genproto/googleapis/api v0.0.0-20240318140521-94a12d6c2237/go.mod h1:Z5Iiy3jtmioajWHDGFk7CeugTyHtPvMHA4UTmUkyalE= google.golang.org/genproto/googleapis/rpc v0.0.0-20240709173604-40e1e62336c5 h1:SbSDUWW1PAO24TNpLdeheoYPd7kllICcLU52x6eD4kQ= From 25dce71f621e9488d03897135914d2041ce3a0dd Mon Sep 17 00:00:00 2001 From: Julien Robert Date: Fri, 19 Jul 2024 10:58:47 +0200 Subject: [PATCH 03/50] refactor(core,types,runtime,x): make HasName not mandatory (#20984) --- core/appmodule/genesis.go | 19 +- core/appmodule/module.go | 5 - core/appmodule/v2/genesis.go | 11 +- .../building-modules/01-module-manager.md | 14 +- runtime/v2/builder.go | 30 +-- runtime/v2/manager.go | 4 +- scripts/mockgen.sh | 1 - simapp/app.go | 48 ++-- testutil/mock/types_mock_appmodule.go | 27 +-- testutil/mock/types_module_module.go | 212 ------------------ testutil/x/counter/module.go | 6 +- types/module/core_module.go | 4 +- types/module/mock_appmodule_test.go | 4 +- types/module/module.go | 33 +-- x/accounts/module.go | 5 +- x/accounts/utils_test.go | 3 +- x/auth/module.go | 4 +- x/auth/vesting/module.go | 10 +- x/authz/module/module.go | 2 +- x/bank/module.go | 2 +- x/circuit/module.go | 2 +- x/consensus/module.go | 2 +- x/distribution/module.go | 2 +- x/epochs/module.go | 2 +- x/evidence/module.go | 2 +- x/feegrant/module/module.go | 2 +- x/genutil/module.go | 2 +- x/gov/module.go | 2 +- x/group/module/module.go | 2 +- x/mint/module.go | 2 +- x/nft/module/module.go | 2 +- x/params/module.go | 2 +- x/protocolpool/module.go | 4 +- x/slashing/module.go | 2 +- x/staking/module.go | 2 +- x/upgrade/module.go | 2 +- 36 files changed, 121 insertions(+), 357 deletions(-) diff --git a/core/appmodule/genesis.go b/core/appmodule/genesis.go index 981b933844d0..a7f1155a59ff 100644 --- a/core/appmodule/genesis.go +++ b/core/appmodule/genesis.go @@ -8,9 +8,20 @@ import ( "cosmossdk.io/core/appmodule/v2" ) +// HasGenesisBasics is the legacy interface for stateless genesis methods. +type HasGenesisBasics interface { + DefaultGenesis() json.RawMessage + ValidateGenesis(json.RawMessage) error +} + // HasGenesis defines a custom genesis handling API implementation. type HasGenesis = appmodule.HasGenesis +// HasABCIGenesis defines a custom genesis handling API implementation for ABCI. +// (stateful genesis methods which returns validator updates) +// Most modules should not implement this interface. +type HasABCIGenesis = appmodule.HasABCIGenesis + // HasGenesisAuto is the extension interface that modules should implement to handle // genesis data and state initialization. // WARNING: This interface is experimental and may change at any time. @@ -30,14 +41,6 @@ type HasGenesisAuto interface { ExportGenesis(context.Context, GenesisTarget) error } -// HasGenesisBasics is the legacy interface for stateless genesis methods. -type HasGenesisBasics interface { - HasName - - DefaultGenesis() json.RawMessage - ValidateGenesis(json.RawMessage) error -} - // GenesisSource is a source for genesis data in JSON format. It may abstract over a // single JSON object or separate files for each field in a JSON object that can // be streamed over. Modules should open a separate io.ReadCloser for each field that diff --git a/core/appmodule/module.go b/core/appmodule/module.go index 8ce2b76a47dc..7aef44a9b8ac 100644 --- a/core/appmodule/module.go +++ b/core/appmodule/module.go @@ -66,11 +66,6 @@ type HasPrecommit interface { Precommit(context.Context) error } -// HasName is an extension interface that must return the appmodule.AppModule's Name. -type HasName interface { - Name() string -} - // HasAminoCodec is an extension interface that module must implement to support JSON encoding and decoding of its types // through amino. This is used in genesis & the CLI client. type HasAminoCodec interface { diff --git a/core/appmodule/v2/genesis.go b/core/appmodule/v2/genesis.go index 4e7b78742df2..967618772f6e 100644 --- a/core/appmodule/v2/genesis.go +++ b/core/appmodule/v2/genesis.go @@ -7,18 +7,27 @@ import ( // HasGenesis defines a custom genesis handling API implementation. // WARNING: this API is meant as a short-term solution to allow for the -// migration of existing modules to the new app module API. It is intended to be replaced by collections +// migration of existing modules to the new app module API. +// It is intended to be replaced by an automatic genesis with collections/orm. type HasGenesis interface { AppModule + DefaultGenesis() json.RawMessage ValidateGenesis(data json.RawMessage) error InitGenesis(ctx context.Context, data json.RawMessage) error ExportGenesis(ctx context.Context) (json.RawMessage, error) } +// HasABCIGenesis defines a custom genesis handling API implementation for ABCI. +// (stateful genesis methods which returns validator updates) +// Most modules should not implement this interface. type HasABCIGenesis interface { + AppModule + DefaultGenesis() json.RawMessage + ValidateGenesis(data json.RawMessage) error InitGenesis(ctx context.Context, data json.RawMessage) ([]ValidatorUpdate, error) + ExportGenesis(ctx context.Context) (json.RawMessage, error) } type GenesisDecoder interface { diff --git a/docs/build/building-modules/01-module-manager.md b/docs/build/building-modules/01-module-manager.md index ce9c229ce6d1..5370ae41672f 100644 --- a/docs/build/building-modules/01-module-manager.md +++ b/docs/build/building-modules/01-module-manager.md @@ -30,9 +30,8 @@ There are 2 main application module interfaces: The above interfaces are mostly embedding smaller interfaces (extension interfaces), that defines specific functionalities: - + -* (legacy) `module.HasName`: Allows the module to provide its own name for legacy purposes. * (legacy) [`module.HasGenesisBasics`](#modulehasgenesisbasics): The legacy interface for stateless genesis methods. * (legacy) [`module.HasGenesis`](#modulehasgenesis) for inter-dependent genesis-related module functionalities. * (legacy) [`module.HasABCIGenesis`](#modulehasabcigenesis) for inter-dependent genesis-related module functionalities. @@ -72,19 +71,10 @@ https://github.com/cosmos/cosmos-sdk/blob/eee5e21e1c8d0995b6d4f83b7f55ec0b58d27b * `RegisterGRPCGatewayRoutes(client.Context, *runtime.ServeMux)`: Registers gRPC routes for the module. - -### `HasName` - -```go reference -https://github.com/cosmos/cosmos-sdk/blob/v0.50.0-alpha.0/types/module/module.go#L71-L73 -``` - -* `HasName` is an interface that has a method `Name()`. This method returns the name of the module as a `string`. - ### Genesis :::tip -For easily creating an `AppModule` that only has genesis functionalities, implement `module.HasGenesis/HasABCIGenesis` and `module.HasName`. +For easily creating an `AppModule` that only has genesis functionalities, implement `module.HasGenesis/HasABCIGenesis`. ::: #### `module.HasGenesisBasics` diff --git a/runtime/v2/builder.go b/runtime/v2/builder.go index 0bdf5992d6c5..2618b0f0be5d 100644 --- a/runtime/v2/builder.go +++ b/runtime/v2/builder.go @@ -36,22 +36,26 @@ func (a *AppBuilder[T]) DefaultGenesis() map[string]json.RawMessage { // RegisterModules registers the provided modules with the module manager. // This is the primary hook for integrating with modules which are not registered using the app config. -func (a *AppBuilder[T]) RegisterModules(modules ...appmodulev2.AppModule) error { - for _, appModule := range modules { - if mod, ok := appModule.(appmodule.HasName); ok { - name := mod.Name() - if _, ok := a.app.moduleManager.modules[name]; ok { - return fmt.Errorf("module named %q already exists", name) +func (a *AppBuilder[T]) RegisterModules(modules map[string]appmodulev2.AppModule) error { + for name, appModule := range modules { + // if a (legacy) module implements the HasName interface, check that the name matches + if mod, ok := appModule.(interface{ Name() string }); ok { + if name != mod.Name() { + a.app.logger.Warn(fmt.Sprintf("module name %q does not match name returned by HasName: %q", name, mod.Name())) } - a.app.moduleManager.modules[name] = appModule + } - if mod, ok := appModule.(appmodulev2.HasRegisterInterfaces); ok { - mod.RegisterInterfaces(a.app.interfaceRegistrar) - } + if _, ok := a.app.moduleManager.modules[name]; ok { + return fmt.Errorf("module named %q already exists", name) + } + a.app.moduleManager.modules[name] = appModule - if mod, ok := appModule.(appmodule.HasAminoCodec); ok { - mod.RegisterLegacyAminoCodec(a.app.amino) - } + if mod, ok := appModule.(appmodulev2.HasRegisterInterfaces); ok { + mod.RegisterInterfaces(a.app.interfaceRegistrar) + } + + if mod, ok := appModule.(appmodule.HasAminoCodec); ok { + mod.RegisterLegacyAminoCodec(a.app.amino) } } diff --git a/runtime/v2/manager.go b/runtime/v2/manager.go index ff9102085bad..c947e0b96581 100644 --- a/runtime/v2/manager.go +++ b/runtime/v2/manager.go @@ -106,7 +106,7 @@ func (m *MM[T]) DefaultGenesis() map[string]json.RawMessage { genesisData := make(map[string]json.RawMessage) for name, b := range m.modules { if mod, ok := b.(appmodule.HasGenesisBasics); ok { - genesisData[mod.Name()] = mod.DefaultGenesis() + genesisData[name] = mod.DefaultGenesis() } else if mod, ok := b.(appmodulev2.HasGenesis); ok { genesisData[name] = mod.DefaultGenesis() } else { @@ -121,7 +121,7 @@ func (m *MM[T]) DefaultGenesis() map[string]json.RawMessage { func (m *MM[T]) ValidateGenesis(genesisData map[string]json.RawMessage) error { for name, b := range m.modules { if mod, ok := b.(appmodule.HasGenesisBasics); ok { - if err := mod.ValidateGenesis(genesisData[mod.Name()]); err != nil { + if err := mod.ValidateGenesis(genesisData[name]); err != nil { return err } } else if mod, ok := b.(appmodulev2.HasGenesis); ok { diff --git a/scripts/mockgen.sh b/scripts/mockgen.sh index a82d6e99701e..eef0730c881a 100755 --- a/scripts/mockgen.sh +++ b/scripts/mockgen.sh @@ -12,7 +12,6 @@ $mockgen_cmd -source=orm/model/ormtable/hooks.go -package ormmocks -destination $mockgen_cmd -source=x/nft/expected_keepers.go -package testutil -destination x/nft/testutil/expected_keepers_mocks.go $mockgen_cmd -source=x/feegrant/expected_keepers.go -package testutil -destination x/feegrant/testutil/expected_keepers_mocks.go $mockgen_cmd -source=x/mint/types/expected_keepers.go -package testutil -destination x/mint/testutil/expected_keepers_mocks.go -$mockgen_cmd -source=x/crisis/types/expected_keepers.go -package testutil -destination x/crisis/testutil/expected_keepers_mocks.go $mockgen_cmd -source=x/auth/tx/config/expected_keepers.go -package testutil -destination x/auth/tx/testutil/expected_keepers_mocks.go $mockgen_cmd -source=x/auth/types/expected_keepers.go -package testutil -destination x/auth/testutil/expected_keepers_mocks.go $mockgen_cmd -source=x/auth/ante/expected_keepers.go -package testutil -destination x/auth/ante/testutil/expected_keepers_mocks.go diff --git a/simapp/app.go b/simapp/app.go index d5a0269f8197..64232666e565 100644 --- a/simapp/app.go +++ b/simapp/app.go @@ -19,6 +19,7 @@ import ( reflectionv1 "cosmossdk.io/api/cosmos/reflection/v1" "cosmossdk.io/client/v2/autocli" clienthelpers "cosmossdk.io/client/v2/helpers" + "cosmossdk.io/core/appmodule" "cosmossdk.io/core/log" storetypes "cosmossdk.io/store/types" "cosmossdk.io/x/accounts" @@ -51,6 +52,7 @@ import ( "cosmossdk.io/x/consensus" consensusparamkeeper "cosmossdk.io/x/consensus/keeper" consensusparamtypes "cosmossdk.io/x/consensus/types" + consensustypes "cosmossdk.io/x/consensus/types" distr "cosmossdk.io/x/distribution" distrkeeper "cosmossdk.io/x/distribution/keeper" distrtypes "cosmossdk.io/x/distribution/types" @@ -79,6 +81,7 @@ import ( "cosmossdk.io/x/protocolpool" poolkeeper "cosmossdk.io/x/protocolpool/keeper" pooltypes "cosmossdk.io/x/protocolpool/types" + protocolpooltypes "cosmossdk.io/x/protocolpool/types" "cosmossdk.io/x/slashing" slashingkeeper "cosmossdk.io/x/slashing/keeper" slashingtypes "cosmossdk.io/x/slashing/types" @@ -436,28 +439,29 @@ func NewSimApp( // NOTE: Any module instantiated in the module manager that is later modified // must be passed by reference here. - app.ModuleManager = module.NewManager( - genutil.NewAppModule(appCodec, app.AuthKeeper, app.StakingKeeper, app, txConfig, genutiltypes.DefaultMessageValidator), - accounts.NewAppModule(appCodec, app.AccountsKeeper), - auth.NewAppModule(appCodec, app.AuthKeeper, app.AccountsKeeper, authsims.RandomGenesisAccounts), - vesting.NewAppModule(app.AuthKeeper, app.BankKeeper), - bank.NewAppModule(appCodec, app.BankKeeper, app.AuthKeeper), - feegrantmodule.NewAppModule(appCodec, app.AuthKeeper, app.BankKeeper, app.FeeGrantKeeper, app.interfaceRegistry), - gov.NewAppModule(appCodec, &app.GovKeeper, app.AuthKeeper, app.BankKeeper, app.PoolKeeper), - mint.NewAppModule(appCodec, app.MintKeeper, app.AuthKeeper, nil), - slashing.NewAppModule(appCodec, app.SlashingKeeper, app.AuthKeeper, app.BankKeeper, app.StakingKeeper, app.interfaceRegistry, cometService), - distr.NewAppModule(appCodec, app.DistrKeeper, app.AuthKeeper, app.BankKeeper, app.StakingKeeper, app.PoolKeeper), - staking.NewAppModule(appCodec, app.StakingKeeper, app.AuthKeeper, app.BankKeeper), - upgrade.NewAppModule(app.UpgradeKeeper), - evidence.NewAppModule(appCodec, app.EvidenceKeeper, cometService), - authzmodule.NewAppModule(appCodec, app.AuthzKeeper, app.AuthKeeper, app.BankKeeper, app.interfaceRegistry), - groupmodule.NewAppModule(appCodec, app.GroupKeeper, app.AuthKeeper, app.BankKeeper, app.interfaceRegistry), - nftmodule.NewAppModule(appCodec, app.NFTKeeper, app.AuthKeeper, app.BankKeeper, app.interfaceRegistry), - consensus.NewAppModule(appCodec, app.ConsensusParamsKeeper), - circuit.NewAppModule(appCodec, app.CircuitKeeper), - protocolpool.NewAppModule(appCodec, app.PoolKeeper, app.AuthKeeper, app.BankKeeper), - epochs.NewAppModule(appCodec, app.EpochsKeeper), - ) + app.ModuleManager = module.NewManagerFromMap(map[string]appmodule.AppModule{ + genutiltypes.ModuleName: genutil.NewAppModule(appCodec, app.AuthKeeper, app.StakingKeeper, app, txConfig, genutiltypes.DefaultMessageValidator), + accounts.ModuleName: accounts.NewAppModule(appCodec, app.AccountsKeeper), + authtypes.ModuleName: auth.NewAppModule(appCodec, app.AuthKeeper, app.AccountsKeeper, authsims.RandomGenesisAccounts), + vestingtypes.ModuleName: vesting.NewAppModule(app.AuthKeeper, app.BankKeeper), + banktypes.ModuleName: bank.NewAppModule(appCodec, app.BankKeeper, app.AuthKeeper), + feegrant.ModuleName: feegrantmodule.NewAppModule(appCodec, app.AuthKeeper, app.BankKeeper, app.FeeGrantKeeper, app.interfaceRegistry), + govtypes.ModuleName: gov.NewAppModule(appCodec, &app.GovKeeper, app.AuthKeeper, app.BankKeeper, app.PoolKeeper), + minttypes.ModuleName: mint.NewAppModule(appCodec, app.MintKeeper, app.AuthKeeper, nil), + slashingtypes.ModuleName: slashing.NewAppModule(appCodec, app.SlashingKeeper, app.AuthKeeper, app.BankKeeper, app.StakingKeeper, app.interfaceRegistry, cometService), + distrtypes.ModuleName: distr.NewAppModule(appCodec, app.DistrKeeper, app.AuthKeeper, app.BankKeeper, app.StakingKeeper, app.PoolKeeper), + stakingtypes.ModuleName: staking.NewAppModule(appCodec, app.StakingKeeper, app.AuthKeeper, app.BankKeeper), + upgradetypes.ModuleName: upgrade.NewAppModule(app.UpgradeKeeper), + evidencetypes.ModuleName: evidence.NewAppModule(appCodec, app.EvidenceKeeper, cometService), + authz.ModuleName: authzmodule.NewAppModule(appCodec, app.AuthzKeeper, app.AuthKeeper, app.BankKeeper, app.interfaceRegistry), + group.ModuleName: groupmodule.NewAppModule(appCodec, app.GroupKeeper, app.AuthKeeper, app.BankKeeper, app.interfaceRegistry), + nft.ModuleName: nftmodule.NewAppModule(appCodec, app.NFTKeeper, app.AuthKeeper, app.BankKeeper, app.interfaceRegistry), + consensustypes.ModuleName: consensus.NewAppModule(appCodec, app.ConsensusParamsKeeper), + circuittypes.ModuleName: circuit.NewAppModule(appCodec, app.CircuitKeeper), + protocolpooltypes.ModuleName: protocolpool.NewAppModule(appCodec, app.PoolKeeper, app.AuthKeeper, app.BankKeeper), + epochstypes.ModuleName: epochs.NewAppModule(appCodec, app.EpochsKeeper), + }) + app.ModuleManager.RegisterLegacyAminoCodec(legacyAmino) app.ModuleManager.RegisterInterfaces(interfaceRegistry) diff --git a/testutil/mock/types_mock_appmodule.go b/testutil/mock/types_mock_appmodule.go index 3c9c7908d020..b0b94179ae99 100644 --- a/testutil/mock/types_mock_appmodule.go +++ b/testutil/mock/types_mock_appmodule.go @@ -10,6 +10,7 @@ import ( reflect "reflect" appmodule "cosmossdk.io/core/appmodule" + appmodule0 "cosmossdk.io/core/appmodule/v2" types "github.com/cosmos/cosmos-sdk/types" module "github.com/cosmos/cosmos-sdk/types/module" gomock "github.com/golang/mock/gomock" @@ -253,33 +254,33 @@ func (mr *MockAppModuleWithAllExtensionsABCIMockRecorder) EndBlock(arg0 interfac } // ExportGenesis mocks base method. -func (m *MockAppModuleWithAllExtensionsABCI) ExportGenesis(arg0 context.Context) (json.RawMessage, error) { +func (m *MockAppModuleWithAllExtensionsABCI) ExportGenesis(ctx context.Context) (json.RawMessage, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "ExportGenesis", arg0) + ret := m.ctrl.Call(m, "ExportGenesis", ctx) ret0, _ := ret[0].(json.RawMessage) ret1, _ := ret[1].(error) return ret0, ret1 } // ExportGenesis indicates an expected call of ExportGenesis. -func (mr *MockAppModuleWithAllExtensionsABCIMockRecorder) ExportGenesis(arg0 interface{}) *gomock.Call { +func (mr *MockAppModuleWithAllExtensionsABCIMockRecorder) ExportGenesis(ctx interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ExportGenesis", reflect.TypeOf((*MockAppModuleWithAllExtensionsABCI)(nil).ExportGenesis), arg0) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ExportGenesis", reflect.TypeOf((*MockAppModuleWithAllExtensionsABCI)(nil).ExportGenesis), ctx) } // InitGenesis mocks base method. -func (m *MockAppModuleWithAllExtensionsABCI) InitGenesis(arg0 context.Context, arg1 json.RawMessage) ([]module.ValidatorUpdate, error) { +func (m *MockAppModuleWithAllExtensionsABCI) InitGenesis(ctx context.Context, data json.RawMessage) ([]appmodule0.ValidatorUpdate, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "InitGenesis", arg0, arg1) - ret0, _ := ret[0].([]module.ValidatorUpdate) + ret := m.ctrl.Call(m, "InitGenesis", ctx, data) + ret0, _ := ret[0].([]appmodule0.ValidatorUpdate) ret1, _ := ret[1].(error) return ret0, ret1 } // InitGenesis indicates an expected call of InitGenesis. -func (mr *MockAppModuleWithAllExtensionsABCIMockRecorder) InitGenesis(arg0, arg1 interface{}) *gomock.Call { +func (mr *MockAppModuleWithAllExtensionsABCIMockRecorder) InitGenesis(ctx, data interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "InitGenesis", reflect.TypeOf((*MockAppModuleWithAllExtensionsABCI)(nil).InitGenesis), arg0, arg1) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "InitGenesis", reflect.TypeOf((*MockAppModuleWithAllExtensionsABCI)(nil).InitGenesis), ctx, data) } // IsAppModule mocks base method. @@ -345,17 +346,17 @@ func (mr *MockAppModuleWithAllExtensionsABCIMockRecorder) RegisterServices(arg0 } // ValidateGenesis mocks base method. -func (m *MockAppModuleWithAllExtensionsABCI) ValidateGenesis(arg0 json.RawMessage) error { +func (m *MockAppModuleWithAllExtensionsABCI) ValidateGenesis(data json.RawMessage) error { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "ValidateGenesis", arg0) + ret := m.ctrl.Call(m, "ValidateGenesis", data) ret0, _ := ret[0].(error) return ret0 } // ValidateGenesis indicates an expected call of ValidateGenesis. -func (mr *MockAppModuleWithAllExtensionsABCIMockRecorder) ValidateGenesis(arg0 interface{}) *gomock.Call { +func (mr *MockAppModuleWithAllExtensionsABCIMockRecorder) ValidateGenesis(data interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ValidateGenesis", reflect.TypeOf((*MockAppModuleWithAllExtensionsABCI)(nil).ValidateGenesis), arg0) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ValidateGenesis", reflect.TypeOf((*MockAppModuleWithAllExtensionsABCI)(nil).ValidateGenesis), data) } // MockCoreAppModule is a mock of CoreAppModule interface. diff --git a/testutil/mock/types_module_module.go b/testutil/mock/types_module_module.go index e3327ca7b30d..6e8832ec9cfc 100644 --- a/testutil/mock/types_module_module.go +++ b/testutil/mock/types_module_module.go @@ -6,7 +6,6 @@ package mock import ( context "context" - json "encoding/json" reflect "reflect" legacy "cosmossdk.io/core/legacy" @@ -40,20 +39,6 @@ func (m *MockAppModuleBasic) EXPECT() *MockAppModuleBasicMockRecorder { return m.recorder } -// Name mocks base method. -func (m *MockAppModuleBasic) Name() string { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "Name") - ret0, _ := ret[0].(string) - return ret0 -} - -// Name indicates an expected call of Name. -func (mr *MockAppModuleBasicMockRecorder) Name() *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Name", reflect.TypeOf((*MockAppModuleBasic)(nil).Name)) -} - // RegisterGRPCGatewayRoutes mocks base method. func (m *MockAppModuleBasic) RegisterGRPCGatewayRoutes(arg0 client.Context, arg1 *runtime.ServeMux) { m.ctrl.T.Helper() @@ -139,108 +124,6 @@ func (mr *MockAppModuleMockRecorder) Name() *gomock.Call { return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Name", reflect.TypeOf((*MockAppModule)(nil).Name)) } -// MockHasName is a mock of HasName interface. -type MockHasName struct { - ctrl *gomock.Controller - recorder *MockHasNameMockRecorder -} - -// MockHasNameMockRecorder is the mock recorder for MockHasName. -type MockHasNameMockRecorder struct { - mock *MockHasName -} - -// NewMockHasName creates a new mock instance. -func NewMockHasName(ctrl *gomock.Controller) *MockHasName { - mock := &MockHasName{ctrl: ctrl} - mock.recorder = &MockHasNameMockRecorder{mock} - return mock -} - -// EXPECT returns an object that allows the caller to indicate expected use. -func (m *MockHasName) EXPECT() *MockHasNameMockRecorder { - return m.recorder -} - -// Name mocks base method. -func (m *MockHasName) Name() string { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "Name") - ret0, _ := ret[0].(string) - return ret0 -} - -// Name indicates an expected call of Name. -func (mr *MockHasNameMockRecorder) Name() *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Name", reflect.TypeOf((*MockHasName)(nil).Name)) -} - -// MockHasGenesisBasics is a mock of HasGenesisBasics interface. -type MockHasGenesisBasics struct { - ctrl *gomock.Controller - recorder *MockHasGenesisBasicsMockRecorder -} - -// MockHasGenesisBasicsMockRecorder is the mock recorder for MockHasGenesisBasics. -type MockHasGenesisBasicsMockRecorder struct { - mock *MockHasGenesisBasics -} - -// NewMockHasGenesisBasics creates a new mock instance. -func NewMockHasGenesisBasics(ctrl *gomock.Controller) *MockHasGenesisBasics { - mock := &MockHasGenesisBasics{ctrl: ctrl} - mock.recorder = &MockHasGenesisBasicsMockRecorder{mock} - return mock -} - -// EXPECT returns an object that allows the caller to indicate expected use. -func (m *MockHasGenesisBasics) EXPECT() *MockHasGenesisBasicsMockRecorder { - return m.recorder -} - -// DefaultGenesis mocks base method. -func (m *MockHasGenesisBasics) DefaultGenesis() json.RawMessage { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "DefaultGenesis") - ret0, _ := ret[0].(json.RawMessage) - return ret0 -} - -// DefaultGenesis indicates an expected call of DefaultGenesis. -func (mr *MockHasGenesisBasicsMockRecorder) DefaultGenesis() *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DefaultGenesis", reflect.TypeOf((*MockHasGenesisBasics)(nil).DefaultGenesis)) -} - -// Name mocks base method. -func (m *MockHasGenesisBasics) Name() string { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "Name") - ret0, _ := ret[0].(string) - return ret0 -} - -// Name indicates an expected call of Name. -func (mr *MockHasGenesisBasicsMockRecorder) Name() *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Name", reflect.TypeOf((*MockHasGenesisBasics)(nil).Name)) -} - -// ValidateGenesis mocks base method. -func (m *MockHasGenesisBasics) ValidateGenesis(arg0 json.RawMessage) error { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "ValidateGenesis", arg0) - ret0, _ := ret[0].(error) - return ret0 -} - -// ValidateGenesis indicates an expected call of ValidateGenesis. -func (mr *MockHasGenesisBasicsMockRecorder) ValidateGenesis(arg0 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ValidateGenesis", reflect.TypeOf((*MockHasGenesisBasics)(nil).ValidateGenesis), arg0) -} - // MockHasAminoCodec is a mock of HasAminoCodec interface. type MockHasAminoCodec struct { ctrl *gomock.Controller @@ -311,101 +194,6 @@ func (mr *MockHasGRPCGatewayMockRecorder) RegisterGRPCGatewayRoutes(arg0, arg1 i return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RegisterGRPCGatewayRoutes", reflect.TypeOf((*MockHasGRPCGateway)(nil).RegisterGRPCGatewayRoutes), arg0, arg1) } -// MockHasABCIGenesis is a mock of HasABCIGenesis interface. -type MockHasABCIGenesis struct { - ctrl *gomock.Controller - recorder *MockHasABCIGenesisMockRecorder -} - -// MockHasABCIGenesisMockRecorder is the mock recorder for MockHasABCIGenesis. -type MockHasABCIGenesisMockRecorder struct { - mock *MockHasABCIGenesis -} - -// NewMockHasABCIGenesis creates a new mock instance. -func NewMockHasABCIGenesis(ctrl *gomock.Controller) *MockHasABCIGenesis { - mock := &MockHasABCIGenesis{ctrl: ctrl} - mock.recorder = &MockHasABCIGenesisMockRecorder{mock} - return mock -} - -// EXPECT returns an object that allows the caller to indicate expected use. -func (m *MockHasABCIGenesis) EXPECT() *MockHasABCIGenesisMockRecorder { - return m.recorder -} - -// DefaultGenesis mocks base method. -func (m *MockHasABCIGenesis) DefaultGenesis() json.RawMessage { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "DefaultGenesis") - ret0, _ := ret[0].(json.RawMessage) - return ret0 -} - -// DefaultGenesis indicates an expected call of DefaultGenesis. -func (mr *MockHasABCIGenesisMockRecorder) DefaultGenesis() *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DefaultGenesis", reflect.TypeOf((*MockHasABCIGenesis)(nil).DefaultGenesis)) -} - -// ExportGenesis mocks base method. -func (m *MockHasABCIGenesis) ExportGenesis(arg0 context.Context) (json.RawMessage, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "ExportGenesis", arg0) - ret0, _ := ret[0].(json.RawMessage) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// ExportGenesis indicates an expected call of ExportGenesis. -func (mr *MockHasABCIGenesisMockRecorder) ExportGenesis(arg0 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ExportGenesis", reflect.TypeOf((*MockHasABCIGenesis)(nil).ExportGenesis), arg0) -} - -// InitGenesis mocks base method. -func (m *MockHasABCIGenesis) InitGenesis(arg0 context.Context, arg1 json.RawMessage) ([]module.ValidatorUpdate, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "InitGenesis", arg0, arg1) - ret0, _ := ret[0].([]module.ValidatorUpdate) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// InitGenesis indicates an expected call of InitGenesis. -func (mr *MockHasABCIGenesisMockRecorder) InitGenesis(arg0, arg1 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "InitGenesis", reflect.TypeOf((*MockHasABCIGenesis)(nil).InitGenesis), arg0, arg1) -} - -// Name mocks base method. -func (m *MockHasABCIGenesis) Name() string { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "Name") - ret0, _ := ret[0].(string) - return ret0 -} - -// Name indicates an expected call of Name. -func (mr *MockHasABCIGenesisMockRecorder) Name() *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Name", reflect.TypeOf((*MockHasABCIGenesis)(nil).Name)) -} - -// ValidateGenesis mocks base method. -func (m *MockHasABCIGenesis) ValidateGenesis(arg0 json.RawMessage) error { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "ValidateGenesis", arg0) - ret0, _ := ret[0].(error) - return ret0 -} - -// ValidateGenesis indicates an expected call of ValidateGenesis. -func (mr *MockHasABCIGenesisMockRecorder) ValidateGenesis(arg0 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ValidateGenesis", reflect.TypeOf((*MockHasABCIGenesis)(nil).ValidateGenesis), arg0) -} - // MockHasInvariants is a mock of HasInvariants interface. type MockHasInvariants struct { ctrl *gomock.Controller diff --git a/testutil/x/counter/module.go b/testutil/x/counter/module.go index f5a4a0a68341..39f18857d8a5 100644 --- a/testutil/x/counter/module.go +++ b/testutil/x/counter/module.go @@ -8,12 +8,9 @@ import ( "github.com/cosmos/cosmos-sdk/testutil/x/counter/keeper" "github.com/cosmos/cosmos-sdk/testutil/x/counter/types" - "github.com/cosmos/cosmos-sdk/types/module" ) var ( - _ module.HasName = AppModule{} - _ appmodule.AppModule = AppModule{} _ appmodule.HasRegisterInterfaces = AppModule{} ) @@ -43,7 +40,8 @@ func NewAppModule(keeper keeper.Keeper) AppModule { // ConsensusVersion implements HasConsensusVersion func (AppModule) ConsensusVersion() uint64 { return 1 } -// Name returns the consensus module's name. +// Name returns the module's name. +// Deprecated: kept for legacy reasons. func (AppModule) Name() string { return types.ModuleName } // RegisterInterfaces registers interfaces and implementations of the bank module. diff --git a/types/module/core_module.go b/types/module/core_module.go index 97466ffeb165..34274d35f2c4 100644 --- a/types/module/core_module.go +++ b/types/module/core_module.go @@ -20,7 +20,6 @@ import ( var ( _ appmodule.AppModule = coreAppModuleAdaptor{} - _ HasName = coreAppModuleAdaptor{} _ HasAminoCodec = coreAppModuleAdaptor{} _ HasGRPCGateway = coreAppModuleAdaptor{} _ appmodule.HasRegisterInterfaces = coreAppModuleAdaptor{} @@ -154,7 +153,8 @@ func (c coreAppModuleAdaptor) InitGenesis(ctx context.Context, bz json.RawMessag return nil, nil } -// Name implements HasName +// Name implements legacy Name() interface +// Kept for legacy reasons func (c coreAppModuleAdaptor) Name() string { return c.name } diff --git a/types/module/mock_appmodule_test.go b/types/module/mock_appmodule_test.go index 1be48c882264..5d5782b599ec 100644 --- a/types/module/mock_appmodule_test.go +++ b/types/module/mock_appmodule_test.go @@ -18,18 +18,16 @@ type AppModuleWithAllExtensions interface { appmodulev2.HasConsensusVersion appmodulev2.HasGenesis module.HasABCIEndBlock - module.HasName } // mocks to be used in module tests. type AppModuleWithAllExtensionsABCI interface { module.AppModule module.HasServices - module.HasABCIGenesis + appmodulev2.HasABCIGenesis module.HasInvariants appmodulev2.HasConsensusVersion module.HasABCIEndBlock - module.HasName } // CoreAppModule is solely here for the purpose of generating diff --git a/types/module/module.go b/types/module/module.go index 1d6df7df4e30..7ea5db116bc5 100644 --- a/types/module/module.go +++ b/types/module/module.go @@ -46,34 +46,21 @@ import ( // Deprecated: use the embed extension interfaces instead, when needed. type AppModuleBasic interface { - HasName HasGRPCGateway HasAminoCodec } -// AppModule is the form for an application module. Most of -// its functionality has been moved to extension interfaces. +// AppModule is the form for an application module. +// Most of its functionality has been moved to extension interfaces. // Deprecated: use appmodule.AppModule with a combination of extension interfaces instead. type AppModule interface { - HasName + Name() string appmodulev2.AppModule } -// HasName allows the module to provide its own name for legacy purposes. -// Newer apps should specify the name for their modules using a map -// using NewManagerFromMap. -type HasName interface { - Name() string -} - // HasGenesisBasics is the legacy interface for stateless genesis methods. -type HasGenesisBasics interface { - HasName - - DefaultGenesis() json.RawMessage - ValidateGenesis(json.RawMessage) error -} +type HasGenesisBasics = appmodule.HasGenesisBasics // HasAminoCodec is the interface for modules that have amino codec registration. // Deprecated: modules should not need to register their own amino codecs. @@ -91,11 +78,7 @@ type HasGRPCGateway interface { type HasGenesis = appmodulev2.HasGenesis // HasABCIGenesis is the extension interface for stateful genesis methods which returns validator updates. -type HasABCIGenesis interface { - HasGenesisBasics - InitGenesis(context.Context, json.RawMessage) ([]ValidatorUpdate, error) - ExportGenesis(context.Context) (json.RawMessage, error) -} +type HasABCIGenesis = appmodulev2.HasABCIGenesis // HasInvariants is the interface for registering invariants. type HasInvariants interface { @@ -139,6 +122,7 @@ type Manager struct { } // NewManager creates a new Manager object. +// Deprecated: Use NewManagerFromMap instead. func NewManager(modules ...AppModule) *Manager { moduleMap := make(map[string]appmodule.AppModule) modulesStr := make([]string, 0, len(modules)) @@ -168,7 +152,6 @@ func NewManager(modules ...AppModule) *Manager { } // NewManagerFromMap creates a new Manager object from a map of module names to module implementations. -// This method should be used for apps and modules which have migrated to the cosmossdk.io/core.appmodule.AppModule API. func NewManagerFromMap(moduleMap map[string]appmodule.AppModule) *Manager { simpleModuleMap := make(map[string]appmodule.AppModule) modulesStr := make([]string, 0, len(simpleModuleMap)) @@ -321,7 +304,7 @@ func (m *Manager) DefaultGenesis() map[string]json.RawMessage { genesisData := make(map[string]json.RawMessage) for name, b := range m.Modules { if mod, ok := b.(HasGenesisBasics); ok { - genesisData[mod.Name()] = mod.DefaultGenesis() + genesisData[name] = mod.DefaultGenesis() } else if mod, ok := b.(appmodule.HasGenesis); ok { genesisData[name] = mod.DefaultGenesis() } else { @@ -336,7 +319,7 @@ func (m *Manager) DefaultGenesis() map[string]json.RawMessage { func (m *Manager) ValidateGenesis(genesisData map[string]json.RawMessage) error { for name, b := range m.Modules { if mod, ok := b.(HasGenesisBasics); ok { - if err := mod.ValidateGenesis(genesisData[mod.Name()]); err != nil { + if err := mod.ValidateGenesis(genesisData[name]); err != nil { return err } } else if mod, ok := b.(appmodule.HasGenesis); ok { diff --git a/x/accounts/module.go b/x/accounts/module.go index 2a85cf47180a..8a848141923e 100644 --- a/x/accounts/module.go +++ b/x/accounts/module.go @@ -14,7 +14,6 @@ import ( "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/types/address" - "github.com/cosmos/cosmos-sdk/types/module" "github.com/cosmos/cosmos-sdk/types/msgservice" ) @@ -29,8 +28,6 @@ const ( var ModuleAccountAddress = address.Module(ModuleName) var ( - _ module.HasName = AppModule{} - _ appmodule.AppModule = AppModule{} _ appmodule.HasServices = AppModule{} _ appmodule.HasGenesis = AppModule{} @@ -48,6 +45,8 @@ type AppModule struct { func (m AppModule) IsAppModule() {} +// Name returns the module's name. +// Deprecated: kept for legacy reasons. func (AppModule) Name() string { return ModuleName } func (m AppModule) RegisterInterfaces(registrar registry.InterfaceRegistrar) { diff --git a/x/accounts/utils_test.go b/x/accounts/utils_test.go index 8b6e171607c0..5e1cf037883e 100644 --- a/x/accounts/utils_test.go +++ b/x/accounts/utils_test.go @@ -12,7 +12,6 @@ import ( basev1beta1 "cosmossdk.io/api/cosmos/base/v1beta1" "cosmossdk.io/core/address" "cosmossdk.io/core/event" - "cosmossdk.io/core/log" coretesting "cosmossdk.io/core/testing" coretransaction "cosmossdk.io/core/transaction" "cosmossdk.io/x/accounts/internal/implementation" @@ -74,7 +73,7 @@ func newKeeper(t *testing.T, accounts ...implementation.AccountCreatorFunc) (Kee ctx := coretesting.Context() ss := coretesting.KVStoreService(ctx, "test") - env := runtime.NewEnvironment(ss, log.NewNopLogger(), runtime.EnvWithQueryRouterService(queryRouter), runtime.EnvWithMsgRouterService(msgRouter)) + env := runtime.NewEnvironment(ss, coretesting.NewNopLogger(), runtime.EnvWithQueryRouterService(queryRouter), runtime.EnvWithMsgRouterService(msgRouter)) env.EventService = eventService{} m, err := NewKeeper(codec.NewProtoCodec(ir), env, addressCodec, ir, accounts...) require.NoError(t, err) diff --git a/x/auth/module.go b/x/auth/module.go index d9290c0a8f1f..d440c8756990 100644 --- a/x/auth/module.go +++ b/x/auth/module.go @@ -33,7 +33,6 @@ const ( var ( _ module.AppModuleSimulation = AppModule{} - _ module.HasName = AppModule{} _ appmodulev2.HasGenesis = AppModule{} _ appmodulev2.AppModule = AppModule{} @@ -67,7 +66,8 @@ func NewAppModule( } } -// Name returns the auth module's name. +// Name returns the module's name. +// Deprecated: kept for legacy reasons. func (AppModule) Name() string { return types.ModuleName } diff --git a/x/auth/vesting/module.go b/x/auth/vesting/module.go index 0baec3da3b01..fc85b46f9654 100644 --- a/x/auth/vesting/module.go +++ b/x/auth/vesting/module.go @@ -6,16 +6,9 @@ import ( "cosmossdk.io/core/registry" "cosmossdk.io/x/auth/keeper" "cosmossdk.io/x/auth/vesting/types" - - "github.com/cosmos/cosmos-sdk/types/module" ) -var ( - _ module.AppModule = AppModule{} - _ module.HasName = AppModule{} - - _ appmodule.AppModule = AppModule{} -) +var _ appmodule.AppModule = AppModule{} // AppModule implementing the AppModule interface. type AppModule struct { @@ -34,6 +27,7 @@ func NewAppModule(ak keeper.AccountKeeper, bk types.BankKeeper) AppModule { func (am AppModule) IsAppModule() {} // Name returns the module's name. +// Deprecated: kept for legacy reasons. func (AppModule) Name() string { return types.ModuleName } diff --git a/x/authz/module/module.go b/x/authz/module/module.go index 3d14c8f2cccc..7cdfe4ae7143 100644 --- a/x/authz/module/module.go +++ b/x/authz/module/module.go @@ -28,7 +28,6 @@ import ( const ConsensusVersion = 2 var ( - _ module.HasName = AppModule{} _ module.HasAminoCodec = AppModule{} _ module.HasGRPCGateway = AppModule{} _ module.AppModuleSimulation = AppModule{} @@ -71,6 +70,7 @@ func NewAppModule( func (AppModule) IsAppModule() {} // Name returns the authz module's name. +// Deprecated: kept for legacy reasons. func (AppModule) Name() string { return authz.ModuleName } diff --git a/x/bank/module.go b/x/bank/module.go index 78295ca268e6..66e5ffc6950b 100644 --- a/x/bank/module.go +++ b/x/bank/module.go @@ -28,7 +28,6 @@ import ( const ConsensusVersion = 4 var ( - _ module.HasName = AppModule{} _ module.HasAminoCodec = AppModule{} _ module.HasGRPCGateway = AppModule{} _ module.AppModuleSimulation = AppModule{} @@ -61,6 +60,7 @@ func NewAppModule(cdc codec.Codec, keeper keeper.Keeper, accountKeeper types.Acc func (am AppModule) IsAppModule() {} // Name returns the bank module's name. +// Deprecated: kept for legacy reasons. func (AppModule) Name() string { return types.ModuleName } // RegisterLegacyAminoCodec registers the bank module's types on the LegacyAmino codec. diff --git a/x/circuit/module.go b/x/circuit/module.go index 32dd06677651..7223b74b8ce5 100644 --- a/x/circuit/module.go +++ b/x/circuit/module.go @@ -22,7 +22,6 @@ import ( const ConsensusVersion = 1 var ( - _ module.HasName = AppModule{} _ module.HasGRPCGateway = AppModule{} _ appmodule.AppModule = AppModule{} @@ -41,6 +40,7 @@ type AppModule struct { func (AppModule) IsAppModule() {} // Name returns the circuit module's name. +// Deprecated: kept for legacy reasons. func (AppModule) Name() string { return types.ModuleName } // RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the circuit module. diff --git a/x/consensus/module.go b/x/consensus/module.go index 4ef57fcb39e6..02504cfcff19 100644 --- a/x/consensus/module.go +++ b/x/consensus/module.go @@ -21,7 +21,6 @@ import ( const ConsensusVersion = 1 var ( - _ module.HasName = AppModule{} _ module.HasAminoCodec = AppModule{} _ module.HasGRPCGateway = AppModule{} @@ -47,6 +46,7 @@ func NewAppModule(cdc codec.Codec, keeper keeper.Keeper) AppModule { func (AppModule) IsAppModule() {} // Name returns the consensus module's name. +// Deprecated: kept for legacy reasons. func (AppModule) Name() string { return types.ModuleName } // RegisterLegacyAminoCodec registers the consensus module's types on the LegacyAmino codec. diff --git a/x/distribution/module.go b/x/distribution/module.go index 12db17e3089a..bd0d3c6d3c89 100644 --- a/x/distribution/module.go +++ b/x/distribution/module.go @@ -28,7 +28,6 @@ import ( const ConsensusVersion = 4 var ( - _ module.HasName = AppModule{} _ module.HasAminoCodec = AppModule{} _ module.HasGRPCGateway = AppModule{} _ module.AppModuleSimulation = AppModule{} @@ -71,6 +70,7 @@ func NewAppModule( func (am AppModule) IsAppModule() {} // Name returns the distribution module's name. +// Deprecated: kept for legacy reasons. func (AppModule) Name() string { return types.ModuleName } diff --git a/x/epochs/module.go b/x/epochs/module.go index 8365f189cfa2..211ec0d49b58 100644 --- a/x/epochs/module.go +++ b/x/epochs/module.go @@ -21,7 +21,6 @@ import ( ) var ( - _ module.HasName = AppModule{} _ module.HasAminoCodec = AppModule{} _ module.HasGRPCGateway = AppModule{} _ module.AppModuleSimulation = AppModule{} @@ -51,6 +50,7 @@ func NewAppModule(cdc codec.Codec, keeper *keeper.Keeper) AppModule { func (am AppModule) IsAppModule() {} // Name returns the epochs module's name. +// Deprecated: kept for legacy reasons. func (AppModule) Name() string { return types.ModuleName } diff --git a/x/evidence/module.go b/x/evidence/module.go index 22756148485d..9de5e4297033 100644 --- a/x/evidence/module.go +++ b/x/evidence/module.go @@ -26,7 +26,6 @@ import ( ) var ( - _ module.HasName = AppModule{} _ module.HasAminoCodec = AppModule{} _ module.HasGRPCGateway = AppModule{} _ module.AppModuleSimulation = AppModule{} @@ -61,6 +60,7 @@ func NewAppModule(cdc codec.Codec, keeper keeper.Keeper, cometService comet.Serv func (am AppModule) IsAppModule() {} // Name returns the evidence module's name. +// Deprecated: kept for legacy reasons. func (AppModule) Name() string { return types.ModuleName } diff --git a/x/feegrant/module/module.go b/x/feegrant/module/module.go index 237705f5b997..9be56adea2f7 100644 --- a/x/feegrant/module/module.go +++ b/x/feegrant/module/module.go @@ -24,7 +24,6 @@ import ( ) var ( - _ module.HasName = AppModule{} _ module.HasAminoCodec = AppModule{} _ module.HasGRPCGateway = AppModule{} _ module.AppModuleSimulation = AppModule{} @@ -62,6 +61,7 @@ func NewAppModule(cdc codec.Codec, ak feegrant.AccountKeeper, bk feegrant.BankKe func (AppModule) IsAppModule() {} // Name returns the feegrant module's name. +// Deprecated: kept for legacy reasons. func (AppModule) Name() string { return feegrant.ModuleName } diff --git a/x/genutil/module.go b/x/genutil/module.go index 89cc972b7113..df3b8d85dd51 100644 --- a/x/genutil/module.go +++ b/x/genutil/module.go @@ -16,7 +16,6 @@ import ( ) var ( - _ module.HasName = AppModule{} _ module.HasABCIGenesis = AppModule{} _ appmodule.AppModule = AppModule{} @@ -56,6 +55,7 @@ func NewAppModule( func (AppModule) IsAppModule() {} // Name returns the genutil module's name. +// Deprecated: kept for legacy reasons. func (AppModule) Name() string { return types.ModuleName } diff --git a/x/gov/module.go b/x/gov/module.go index 38ff794653ef..b64042321d0d 100644 --- a/x/gov/module.go +++ b/x/gov/module.go @@ -30,7 +30,6 @@ import ( const ConsensusVersion = 6 var ( - _ module.HasName = AppModule{} _ module.HasAminoCodec = AppModule{} _ module.HasGRPCGateway = AppModule{} _ module.AppModuleSimulation = AppModule{} @@ -75,6 +74,7 @@ func NewAppModule( func (am AppModule) IsAppModule() {} // Name returns the gov module's name. +// Deprecated: kept for legacy reasons. func (AppModule) Name() string { return govtypes.ModuleName } diff --git a/x/group/module/module.go b/x/group/module/module.go index c66756457517..a27854829d7f 100644 --- a/x/group/module/module.go +++ b/x/group/module/module.go @@ -29,7 +29,6 @@ import ( const ConsensusVersion = 2 var ( - _ module.HasName = AppModule{} _ module.HasAminoCodec = AppModule{} _ module.HasGRPCGateway = AppModule{} _ module.AppModuleSimulation = AppModule{} @@ -67,6 +66,7 @@ func NewAppModule(cdc codec.Codec, keeper keeper.Keeper, ak group.AccountKeeper, func (AppModule) IsAppModule() {} // Name returns the group module's name. +// Deprecated: kept for legacy reasons. func (am AppModule) Name() string { return group.ModuleName } diff --git a/x/mint/module.go b/x/mint/module.go index 990f281edc4a..0c5fea08dafb 100644 --- a/x/mint/module.go +++ b/x/mint/module.go @@ -25,7 +25,6 @@ import ( const ConsensusVersion = 3 var ( - _ module.HasName = AppModule{} _ module.HasAminoCodec = AppModule{} _ module.HasGRPCGateway = AppModule{} _ module.AppModuleSimulation = AppModule{} @@ -76,6 +75,7 @@ func NewAppModule( func (AppModule) IsAppModule() {} // Name returns the mint module's name. +// Deprecated: kept for legacy reasons. func (AppModule) Name() string { return types.ModuleName } diff --git a/x/nft/module/module.go b/x/nft/module/module.go index 7c662cec1229..70672dbab19a 100644 --- a/x/nft/module/module.go +++ b/x/nft/module/module.go @@ -22,7 +22,6 @@ import ( ) var ( - _ module.HasName = AppModule{} _ module.HasGRPCGateway = AppModule{} _ module.AppModuleSimulation = AppModule{} @@ -58,6 +57,7 @@ func NewAppModule(cdc codec.Codec, keeper keeper.Keeper, ak nft.AccountKeeper, b func (AppModule) IsAppModule() {} // Name returns the nft module's name. +// Deprecated: kept for legacy reasons. func (AppModule) Name() string { return nft.ModuleName } diff --git a/x/params/module.go b/x/params/module.go index bba2218ea3e0..097056bcd4a6 100644 --- a/x/params/module.go +++ b/x/params/module.go @@ -18,7 +18,6 @@ import ( ) var ( - _ module.HasName = AppModule{} _ module.HasAminoCodec = AppModule{} _ module.HasGRPCGateway = AppModule{} _ module.AppModuleSimulation = AppModule{} @@ -47,6 +46,7 @@ func NewAppModule(k keeper.Keeper) AppModule { func (am AppModule) IsAppModule() {} // Name returns the params module's name. +// Deprecated: kept for legacy reasons. func (AppModule) Name() string { return proposal.ModuleName } diff --git a/x/protocolpool/module.go b/x/protocolpool/module.go index e8cfd7bde294..882da6eb6fc8 100644 --- a/x/protocolpool/module.go +++ b/x/protocolpool/module.go @@ -22,7 +22,6 @@ import ( const ConsensusVersion = 1 var ( - _ module.HasName = AppModule{} _ module.HasGRPCGateway = AppModule{} _ module.AppModuleSimulation = AppModule{} @@ -55,7 +54,8 @@ func NewAppModule(cdc codec.Codec, keeper keeper.Keeper, // IsAppModule implements the appmodule.AppModule interface. func (AppModule) IsAppModule() {} -// Name returns the pool module's name. +// Name returns the protocolpool module's name. +// Deprecated: kept for legacy reasons. func (AppModule) Name() string { return types.ModuleName } // RegisterGRPCGatewayRoutes registers the gRPC Gateway routes diff --git a/x/slashing/module.go b/x/slashing/module.go index f3a8a3f3e506..5b6534fd529b 100644 --- a/x/slashing/module.go +++ b/x/slashing/module.go @@ -27,7 +27,6 @@ import ( const ConsensusVersion = 4 var ( - _ module.HasName = AppModule{} _ module.HasAminoCodec = AppModule{} _ module.HasGRPCGateway = AppModule{} _ module.AppModuleSimulation = AppModule{} @@ -77,6 +76,7 @@ func NewAppModule( func (AppModule) IsAppModule() {} // Name returns the slashing module's name. +// Deprecated: kept for legacy reasons. func (AppModule) Name() string { return types.ModuleName } diff --git a/x/staking/module.go b/x/staking/module.go index f8080c182992..927c4f5d7873 100644 --- a/x/staking/module.go +++ b/x/staking/module.go @@ -29,7 +29,6 @@ const ( var ( _ module.AppModuleSimulation = AppModule{} - _ module.HasName = AppModule{} _ module.HasAminoCodec = AppModule{} _ module.HasGRPCGateway = AppModule{} _ module.HasInvariants = AppModule{} @@ -71,6 +70,7 @@ func NewAppModule( func (am AppModule) IsAppModule() {} // Name returns the staking module's name. +// Deprecated: kept for legacy reasons. func (AppModule) Name() string { return types.ModuleName } diff --git a/x/upgrade/module.go b/x/upgrade/module.go index 76c6e4e4ce38..f18b426c473d 100644 --- a/x/upgrade/module.go +++ b/x/upgrade/module.go @@ -24,7 +24,6 @@ import ( const ConsensusVersion uint64 = 3 var ( - _ module.HasName = AppModule{} _ module.HasAminoCodec = AppModule{} _ module.HasGRPCGateway = AppModule{} @@ -52,6 +51,7 @@ func NewAppModule(keeper *keeper.Keeper) AppModule { func (AppModule) IsAppModule() {} // Name returns the ModuleName +// Deprecated: kept for legacy reasons. func (AppModule) Name() string { return types.ModuleName } From b08c8513d598ada22abffb8143cde5e3f24b009b Mon Sep 17 00:00:00 2001 From: Halimao <1065621723@qq.com> Date: Fri, 19 Jul 2024 17:28:34 +0800 Subject: [PATCH 04/50] test: replace `"cosmossdk.io/core/log"` with `"cosmossdk.io/core/testing"` (#20994) --- tests/sims/authz/operations_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/sims/authz/operations_test.go b/tests/sims/authz/operations_test.go index cec2ff245117..7e59d00a827f 100644 --- a/tests/sims/authz/operations_test.go +++ b/tests/sims/authz/operations_test.go @@ -9,7 +9,7 @@ import ( "github.com/stretchr/testify/suite" "cosmossdk.io/core/header" - "cosmossdk.io/core/log" + coretesting "cosmossdk.io/core/testing" "cosmossdk.io/depinject" _ "cosmossdk.io/x/accounts" // import as blank for app wiring _ "cosmossdk.io/x/auth" // import as blank for app wiring @@ -69,7 +69,7 @@ func (suite *SimTestSuite) SetupTest() { app, err := simtestutil.Setup( depinject.Configs( AppConfig, - depinject.Supply(log.NewNopLogger()), + depinject.Supply(coretesting.NewNopLogger()), ), &suite.codec, &suite.interfaceRegistry, From 095c003495d4fd79032b75400c4e915d3b8da836 Mon Sep 17 00:00:00 2001 From: yukionfire Date: Fri, 19 Jul 2024 17:37:03 +0800 Subject: [PATCH 05/50] chore(x/auth,x/accounts): use `errors.New` to replace `fmt.Errorf` with no parameters (#20993) --- x/accounts/defaults/lockup/lockup.go | 6 +++--- x/accounts/defaults/lockup/utils_test.go | 4 ++-- x/accounts/keeper.go | 4 ++-- x/auth/ante/sigverify.go | 2 +- x/auth/client/cli/tx_multisign.go | 3 ++- x/auth/client/cli/validate_sigs.go | 4 ++-- x/auth/client/tx.go | 7 ++++--- x/auth/migrations/legacytx/stdsign.go | 7 ++++--- x/auth/tx/builder.go | 3 ++- x/auth/tx/config.go | 2 +- x/auth/tx/config/depinject.go | 3 ++- x/auth/tx/sigs.go | 3 ++- x/auth/types/account.go | 2 +- x/auth/types/credentials.go | 3 ++- x/auth/types/params_test.go | 12 ++++++------ x/auth/types/permissions.go | 4 ++-- 16 files changed, 38 insertions(+), 31 deletions(-) diff --git a/x/accounts/defaults/lockup/lockup.go b/x/accounts/defaults/lockup/lockup.go index 08f22b304963..060e656aa273 100644 --- a/x/accounts/defaults/lockup/lockup.go +++ b/x/accounts/defaults/lockup/lockup.go @@ -3,7 +3,7 @@ package lockup import ( "bytes" "context" - "fmt" + "errors" "time" "github.com/cosmos/gogoproto/proto" @@ -349,7 +349,7 @@ func (bva *BaseLockup) WithdrawUnlockedCoins( } } if len(amount) == 0 { - return nil, fmt.Errorf("no tokens available for withdrawing") + return nil, errors.New("no tokens available for withdrawing") } msgSend := &banktypes.MsgSend{ @@ -379,7 +379,7 @@ func (bva *BaseLockup) checkSender(ctx context.Context, sender string) error { return sdkerrors.ErrInvalidAddress.Wrapf("invalid sender address: %s", err.Error()) } if !bytes.Equal(owner, senderBytes) { - return fmt.Errorf("sender is not the owner of this vesting account") + return errors.New("sender is not the owner of this vesting account") } return nil diff --git a/x/accounts/defaults/lockup/utils_test.go b/x/accounts/defaults/lockup/utils_test.go index 56cd3316edea..a7032ceedeb3 100644 --- a/x/accounts/defaults/lockup/utils_test.go +++ b/x/accounts/defaults/lockup/utils_test.go @@ -2,7 +2,7 @@ package lockup import ( "context" - "fmt" + "errors" "testing" gogoproto "github.com/cosmos/gogoproto/proto" @@ -87,7 +87,7 @@ func newMockContext(t *testing.T) (context.Context, store.KVStoreService) { case "/cosmos.bank.v1beta1.MsgSend": return &banktypes.MsgSendResponse{}, nil default: - return nil, fmt.Errorf("unrecognized request type") + return nil, errors.New("unrecognized request type") } }, func(ctx context.Context, req, resp ProtoMsg) error { _, ok := req.(*banktypes.QueryBalanceRequest) diff --git a/x/accounts/keeper.go b/x/accounts/keeper.go index 98b27e5eab03..91ef5d707c82 100644 --- a/x/accounts/keeper.go +++ b/x/accounts/keeper.go @@ -331,10 +331,10 @@ func (k Keeper) makeAccountContext(ctx context.Context, accountNumber uint64, ac nil, nil, func(ctx context.Context, sender []byte, msg, msgResp implementation.ProtoMsg) error { - return fmt.Errorf("cannot execute in query context") + return errors.New("cannot execute in query context") }, func(ctx context.Context, sender []byte, msg implementation.ProtoMsg) (implementation.ProtoMsg, error) { - return nil, fmt.Errorf("cannot execute in query context") + return nil, errors.New("cannot execute in query context") }, k.queryModule, ) diff --git a/x/auth/ante/sigverify.go b/x/auth/ante/sigverify.go index c16ec1e40b5b..1856f2c311f6 100644 --- a/x/auth/ante/sigverify.go +++ b/x/auth/ante/sigverify.go @@ -623,7 +623,7 @@ func CountSubKeys(pub cryptotypes.PubKey) int { // as well as the aggregated signature. func signatureDataToBz(data signing.SignatureData) ([][]byte, error) { if data == nil { - return nil, fmt.Errorf("got empty SignatureData") + return nil, errors.New("got empty SignatureData") } switch data := data.(type) { diff --git a/x/auth/client/cli/tx_multisign.go b/x/auth/client/cli/tx_multisign.go index 41ff8a25b058..ced781fed845 100644 --- a/x/auth/client/cli/tx_multisign.go +++ b/x/auth/client/cli/tx_multisign.go @@ -1,6 +1,7 @@ package cli import ( + "errors" "fmt" "os" "strings" @@ -137,7 +138,7 @@ func makeMultiSignCmd() func(cmd *cobra.Command, args []string) (err error) { } if txFactory.ChainID() == "" { - return fmt.Errorf("set the chain id with either the --chain-id flag or config file") + return errors.New("set the chain id with either the --chain-id flag or config file") } for _, sig := range sigs { diff --git a/x/auth/client/cli/validate_sigs.go b/x/auth/client/cli/validate_sigs.go index 846fc8cee581..0638f78c38a9 100644 --- a/x/auth/client/cli/validate_sigs.go +++ b/x/auth/client/cli/validate_sigs.go @@ -2,7 +2,7 @@ package cli import ( "bytes" - "fmt" + "errors" "github.com/spf13/cobra" "google.golang.org/protobuf/types/known/anypb" @@ -52,7 +52,7 @@ func makeValidateSignaturesCmd() func(cmd *cobra.Command, args []string) error { } if !printAndValidateSigs(cmd, clientCtx, txBldr.ChainID(), stdTx, clientCtx.Offline) { - return fmt.Errorf("signatures validation failed") + return errors.New("signatures validation failed") } return nil diff --git a/x/auth/client/tx.go b/x/auth/client/tx.go index 0f505ccc3c87..ce0800eaf88f 100644 --- a/x/auth/client/tx.go +++ b/x/auth/client/tx.go @@ -3,6 +3,7 @@ package client import ( "bufio" "bytes" + "errors" "fmt" "io" "os" @@ -15,7 +16,7 @@ import ( "github.com/cosmos/cosmos-sdk/client/tx" "github.com/cosmos/cosmos-sdk/crypto/keyring" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/types/errors" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/cosmos/cosmos-sdk/types/tx/signing" ) @@ -53,7 +54,7 @@ func SignTx(txFactory tx.Factory, clientCtx client.Context, name string, txBuild return err } if !isTxSigner(addr, signers) { - return fmt.Errorf("%w: %s", errors.ErrorInvalidSigner, name) + return fmt.Errorf("%w: %s", sdkerrors.ErrorInvalidSigner, name) } if !offline { txFactory, err = populateAccountFromState(txFactory, clientCtx, addr) @@ -142,7 +143,7 @@ func ReadTxsFromFile(ctx client.Context, filename string) (txs []sdk.Tx, err err // Unlike ReadTxFromFile, this function does not decode the txs. func ReadTxsFromInput(txCfg client.TxConfig, filenames ...string) (scanner *BatchScanner, err error) { if len(filenames) == 0 { - return nil, fmt.Errorf("no file name provided") + return nil, errors.New("no file name provided") } var infile io.Reader = os.Stdin diff --git a/x/auth/migrations/legacytx/stdsign.go b/x/auth/migrations/legacytx/stdsign.go index e8d00f67594c..71887fb26c99 100644 --- a/x/auth/migrations/legacytx/stdsign.go +++ b/x/auth/migrations/legacytx/stdsign.go @@ -2,11 +2,12 @@ package legacytx import ( "encoding/json" + "errors" "fmt" "sigs.k8s.io/yaml" - "cosmossdk.io/errors" + errorsmod "cosmossdk.io/errors" "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/codec/legacy" @@ -62,7 +63,7 @@ func mustSortJSON(bz []byte) []byte { // Deprecated: Please use x/tx/signing/aminojson instead. func StdSignBytes(chainID string, accnum, sequence, timeout uint64, fee StdFee, msgs []sdk.Msg, memo string) []byte { if RegressionTestingAminoCodec == nil { - panic(fmt.Errorf("must set RegressionTestingAminoCodec before calling StdSignBytes")) + panic(errors.New("must set RegressionTestingAminoCodec before calling StdSignBytes")) } msgsBytes := make([]json.RawMessage, 0, len(msgs)) for _, msg := range msgs { @@ -172,7 +173,7 @@ func pubKeySigToSigData(cdc *codec.LegacyAmino, key cryptotypes.PubKey, sig []by if bitArray.GetIndex(i) { data, err := pubKeySigToSigData(cdc, pubKeys[i], multiSig.Sigs[sigIdx]) if err != nil { - return nil, errors.Wrapf(err, "Unable to convert Signature to SigData %d", sigIdx) + return nil, errorsmod.Wrapf(err, "Unable to convert Signature to SigData %d", sigIdx) } sigDatas[sigIdx] = data diff --git a/x/auth/tx/builder.go b/x/auth/tx/builder.go index 506412b23f6c..84dd54bb3002 100644 --- a/x/auth/tx/builder.go +++ b/x/auth/tx/builder.go @@ -1,6 +1,7 @@ package tx import ( + "errors" "fmt" "google.golang.org/protobuf/proto" @@ -241,7 +242,7 @@ func (w *builder) SetNonCriticalExtensionOptions(extOpts ...*codectypes.Any) { w.nonCriticalExtensionOptions = extOpts } -func (w *builder) AddAuxSignerData(data tx.AuxSignerData) error { return fmt.Errorf("not supported") } +func (w *builder) AddAuxSignerData(data tx.AuxSignerData) error { return errors.New("not supported") } func (w *builder) getFee() (fee *txv1beta1.Fee, err error) { granterStr := "" diff --git a/x/auth/tx/config.go b/x/auth/tx/config.go index 2b7675cd257f..bd9811a76c55 100644 --- a/x/auth/tx/config.go +++ b/x/auth/tx/config.go @@ -149,7 +149,7 @@ func NewSigningHandlerMap(configOpts ConfigOptions) (*txsigning.HandlerMap, erro TypeResolver: signingOpts.TypeResolver, }) if configOpts.TextualCoinMetadataQueryFn == nil { - return nil, fmt.Errorf("cannot enable SIGN_MODE_TEXTUAL without a TextualCoinMetadataQueryFn") + return nil, errors.New("cannot enable SIGN_MODE_TEXTUAL without a TextualCoinMetadataQueryFn") } if err != nil { return nil, err diff --git a/x/auth/tx/config/depinject.go b/x/auth/tx/config/depinject.go index f3b02370e8d2..d85c2921fc8c 100644 --- a/x/auth/tx/config/depinject.go +++ b/x/auth/tx/config/depinject.go @@ -2,6 +2,7 @@ package tx import ( "context" + "errors" "fmt" gogoproto "github.com/cosmos/gogoproto/proto" @@ -144,7 +145,7 @@ func ProvideModule(in ModuleInputs) ModuleOutputs { func newAnteHandler(txConfig client.TxConfig, in ModuleInputs) (sdk.AnteHandler, error) { if in.BankKeeper == nil { - return nil, fmt.Errorf("both AccountKeeper and BankKeeper are required") + return nil, errors.New("both AccountKeeper and BankKeeper are required") } anteHandler, err := ante.NewAnteHandler( diff --git a/x/auth/tx/sigs.go b/x/auth/tx/sigs.go index 1c182567f9cf..7885cf6b3343 100644 --- a/x/auth/tx/sigs.go +++ b/x/auth/tx/sigs.go @@ -1,6 +1,7 @@ package tx import ( + "errors" "fmt" txv1beta1 "cosmossdk.io/api/cosmos/tx/v1beta1" @@ -105,7 +106,7 @@ func decodeMultisignatures(bz []byte) ([][]byte, error) { // malleability in the protobuf message. Basically an attacker could bloat a MultiSignature message with unknown // fields, thus bloating the transaction and causing it to fail. if len(multisig.XXX_unrecognized) > 0 { - return nil, fmt.Errorf("rejecting unrecognized fields found in MultiSignature") + return nil, errors.New("rejecting unrecognized fields found in MultiSignature") } return multisig.Signatures, nil } diff --git a/x/auth/types/account.go b/x/auth/types/account.go index 791803174b5c..263c5ee41ee1 100644 --- a/x/auth/types/account.go +++ b/x/auth/types/account.go @@ -207,7 +207,7 @@ func (ma ModuleAccount) GetPermissions() []string { // SetPubKey - Implements AccountI func (ma ModuleAccount) SetPubKey(pubKey cryptotypes.PubKey) error { - return fmt.Errorf("not supported for module accounts") + return errors.New("not supported for module accounts") } // Validate checks for errors on the account fields diff --git a/x/auth/types/credentials.go b/x/auth/types/credentials.go index 4c63fc8d8c41..c2da54c22528 100644 --- a/x/auth/types/credentials.go +++ b/x/auth/types/credentials.go @@ -2,6 +2,7 @@ package types import ( "bytes" + "errors" "fmt" cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" @@ -12,7 +13,7 @@ import ( // NewBaseAccountWithPubKey creates an account with an a pubkey. func NewBaseAccountWithPubKey(pubkey cryptotypes.PubKey) (*BaseAccount, error) { if pubkey == nil { - return nil, fmt.Errorf("pubkey cannot be nil") + return nil, errors.New("pubkey cannot be nil") } baseAccount := NewBaseAccountWithAddress(sdk.AccAddress(pubkey.Address())) diff --git a/x/auth/types/params_test.go b/x/auth/types/params_test.go index fdef7174cf09..8f6684403297 100644 --- a/x/auth/types/params_test.go +++ b/x/auth/types/params_test.go @@ -1,7 +1,7 @@ package types_test import ( - "fmt" + "errors" "testing" "github.com/stretchr/testify/require" @@ -26,15 +26,15 @@ func TestParams_Validate(t *testing.T) { }{ {"default params", types.DefaultParams(), nil}, {"invalid tx signature limit", types.NewParams(types.DefaultMaxMemoCharacters, 0, types.DefaultTxSizeCostPerByte, - types.DefaultSigVerifyCostED25519, types.DefaultSigVerifyCostSecp256k1), fmt.Errorf("invalid tx signature limit: 0")}, + types.DefaultSigVerifyCostED25519, types.DefaultSigVerifyCostSecp256k1), errors.New("invalid tx signature limit: 0")}, {"invalid ED25519 signature verification cost", types.NewParams(types.DefaultMaxMemoCharacters, types.DefaultTxSigLimit, types.DefaultTxSizeCostPerByte, - 0, types.DefaultSigVerifyCostSecp256k1), fmt.Errorf("invalid ED25519 signature verification cost: 0")}, + 0, types.DefaultSigVerifyCostSecp256k1), errors.New("invalid ED25519 signature verification cost: 0")}, {"invalid SECK256k1 signature verification cost", types.NewParams(types.DefaultMaxMemoCharacters, types.DefaultTxSigLimit, types.DefaultTxSizeCostPerByte, - types.DefaultSigVerifyCostED25519, 0), fmt.Errorf("invalid SECK256k1 signature verification cost: 0")}, + types.DefaultSigVerifyCostED25519, 0), errors.New("invalid SECK256k1 signature verification cost: 0")}, {"invalid max memo characters", types.NewParams(0, types.DefaultTxSigLimit, types.DefaultTxSizeCostPerByte, - types.DefaultSigVerifyCostED25519, types.DefaultSigVerifyCostSecp256k1), fmt.Errorf("invalid max memo characters: 0")}, + types.DefaultSigVerifyCostED25519, types.DefaultSigVerifyCostSecp256k1), errors.New("invalid max memo characters: 0")}, {"invalid tx size cost per byte", types.NewParams(types.DefaultMaxMemoCharacters, types.DefaultTxSigLimit, 0, - types.DefaultSigVerifyCostED25519, types.DefaultSigVerifyCostSecp256k1), fmt.Errorf("invalid tx size cost per byte: 0")}, + types.DefaultSigVerifyCostED25519, types.DefaultSigVerifyCostSecp256k1), errors.New("invalid tx size cost per byte: 0")}, } for _, tt := range tests { tt := tt diff --git a/x/auth/types/permissions.go b/x/auth/types/permissions.go index 8547235003c4..6d78a4b56a8d 100644 --- a/x/auth/types/permissions.go +++ b/x/auth/types/permissions.go @@ -1,7 +1,7 @@ package types import ( - "fmt" + "errors" "strings" sdk "github.com/cosmos/cosmos-sdk/types" @@ -52,7 +52,7 @@ func (pa PermissionsForAddress) GetPermissions() []string { func validatePermissions(permissions ...string) error { for _, perm := range permissions { if strings.TrimSpace(perm) == "" { - return fmt.Errorf("module permission is empty") + return errors.New("module permission is empty") } } return nil From b0652195d814bd34f7fd9923a089a8fd3b57299f Mon Sep 17 00:00:00 2001 From: Alexander Peters Date: Fri, 19 Jul 2024 15:30:09 +0200 Subject: [PATCH 06/50] test(x/slashing): fix slashing sims (#20995) --- x/slashing/simulation/operations.go | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/x/slashing/simulation/operations.go b/x/slashing/simulation/operations.go index 7dce1d345157..45f61af3a999 100644 --- a/x/slashing/simulation/operations.go +++ b/x/slashing/simulation/operations.go @@ -93,16 +93,9 @@ func SimulateMsgUnjail( if err != nil { return simtypes.NoOpMsg(types.ModuleName, msgType, "unable to get validator consensus key"), nil, err } - info, err := k.ValidatorSigningInfo.Get(ctx, consAddr) - if err != nil { - return simtypes.NoOpMsg(types.ModuleName, msgType, "unable to find validator signing info"), nil, err // skip - } - - selfDel, err := sk.Delegation(ctx, simAccount.Address, bz) - if err != nil { - return simtypes.NoOpMsg(types.ModuleName, msgType, "unable to get self delegation"), nil, err - } + info, _ := k.ValidatorSigningInfo.Get(ctx, consAddr) + selfDel, _ := sk.Delegation(ctx, simAccount.Address, bz) if selfDel == nil { return simtypes.NoOpMsg(types.ModuleName, msgType, "self delegation is nil"), nil, nil // skip } @@ -112,7 +105,7 @@ func SimulateMsgUnjail( fees, err := simtypes.RandomFees(r, spendable) if err != nil { - return simtypes.NoOpMsg(types.ModuleName, msgType, "unable to generate fees"), nil, err + return simtypes.NoOpMsg(types.ModuleName, msgType, "unable to generate fees"), nil, nil } msg := types.NewMsgUnjail(validator.GetOperator()) @@ -140,6 +133,7 @@ func SimulateMsgUnjail( // - self delegation too low if info.Tombstoned || ctx.HeaderInfo().Time.Before(info.JailedUntil) || + selfDel.GetShares().IsNil() || validator.TokensFromShares(selfDel.GetShares()).TruncateInt().LT(validator.GetMinSelfDelegation()) { if res != nil && err == nil { if info.Tombstoned { @@ -148,7 +142,8 @@ func SimulateMsgUnjail( if ctx.HeaderInfo().Time.Before(info.JailedUntil) { return simtypes.NewOperationMsg(msg, true, ""), nil, errors.New("validator unjailed while validator still in jail period") } - if validator.TokensFromShares(selfDel.GetShares()).TruncateInt().LT(validator.GetMinSelfDelegation()) { + if selfDel.GetShares().IsNil() || + validator.TokensFromShares(selfDel.GetShares()).TruncateInt().LT(validator.GetMinSelfDelegation()) { return simtypes.NewOperationMsg(msg, true, ""), nil, errors.New("validator unjailed even though self-delegation too low") } } From b19d6e3a481a7f2693c73b8b92f113ba210baaa7 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 19 Jul 2024 13:57:20 +0000 Subject: [PATCH 07/50] build(deps): Bump cosmossdk.io/x/upgrade from 0.1.3 to 0.1.4 in /tools/cosmovisor (#20982) Co-authored-by: Julien Robert --- tools/cosmovisor/go.mod | 4 ++-- tools/cosmovisor/go.sum | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/tools/cosmovisor/go.mod b/tools/cosmovisor/go.mod index 76129739f97c..aacd169fd638 100644 --- a/tools/cosmovisor/go.mod +++ b/tools/cosmovisor/go.mod @@ -6,7 +6,7 @@ toolchain go1.22.4 require ( cosmossdk.io/log v1.3.1 - cosmossdk.io/x/upgrade v0.1.3 + cosmossdk.io/x/upgrade v0.1.4 github.com/otiai10/copy v1.14.0 github.com/pelletier/go-toml/v2 v2.2.2 github.com/spf13/cobra v1.8.1 @@ -47,7 +47,7 @@ require ( github.com/cockroachdb/pebble v1.1.0 // indirect github.com/cockroachdb/redact v1.1.5 // indirect github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06 // indirect - github.com/cometbft/cometbft v0.38.8 // indirect + github.com/cometbft/cometbft v0.38.9 // indirect github.com/cometbft/cometbft-db v0.12.0 // indirect github.com/cosmos/btcutil v1.0.5 // indirect github.com/cosmos/cosmos-db v1.0.2 // indirect diff --git a/tools/cosmovisor/go.sum b/tools/cosmovisor/go.sum index 8bc8cb3f59e2..713b07d3ae27 100644 --- a/tools/cosmovisor/go.sum +++ b/tools/cosmovisor/go.sum @@ -206,8 +206,8 @@ cosmossdk.io/store v1.1.0 h1:LnKwgYMc9BInn9PhpTFEQVbL9UK475G2H911CGGnWHk= cosmossdk.io/store v1.1.0/go.mod h1:oZfW/4Fc/zYqu3JmQcQdUJ3fqu5vnYTn3LZFFy8P8ng= cosmossdk.io/x/tx v0.13.3 h1:Ha4mNaHmxBc6RMun9aKuqul8yHiL78EKJQ8g23Zf73g= cosmossdk.io/x/tx v0.13.3/go.mod h1:I8xaHv0rhUdIvIdptKIqzYy27+n2+zBVaxO6fscFhys= -cosmossdk.io/x/upgrade v0.1.3 h1:q4XpXc6zp0dX6x74uBtfN6+J7ikaQev5Bla6Q0ADLK8= -cosmossdk.io/x/upgrade v0.1.3/go.mod h1:jOdQhnaY5B8CDUoUbed23/Lre0Dk+r6BMQE40iKlVVQ= +cosmossdk.io/x/upgrade v0.1.4 h1:/BWJim24QHoXde8Bc64/2BSEB6W4eTydq0X/2f8+g38= +cosmossdk.io/x/upgrade v0.1.4/go.mod h1:9v0Aj+fs97O+Ztw+tG3/tp5JSlrmT7IcFhAebQHmOPo= dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= filippo.io/edwards25519 v1.1.0 h1:FNf4tywRC1HmFuKW5xopWpigGjJKiJSV0Cqo0cJWDaA= filippo.io/edwards25519 v1.1.0/go.mod h1:BxyFTGdWcka3PhytdK4V28tE5sGfRvvvRV7EaN4VDT4= @@ -312,8 +312,8 @@ github.com/cockroachdb/redact v1.1.5/go.mod h1:BVNblN9mBWFyMyqK1k3AAiSxhvhfK2oOZ github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06 h1:zuQyyAKVxetITBuuhv3BI9cMrmStnpT18zmgmTxunpo= github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06/go.mod h1:7nc4anLGjupUW/PeY5qiNYsdNXj7zopG+eqsS7To5IQ= github.com/codahale/hdrhistogram v0.0.0-20161010025455-3a0bb77429bd/go.mod h1:sE/e/2PUdi/liOCUjSTXgM1o87ZssimdTWN964YiIeI= -github.com/cometbft/cometbft v0.38.8 h1:XyJ9Cu3xqap6xtNxiemrO8roXZ+KS2Zlu7qQ0w1trvU= -github.com/cometbft/cometbft v0.38.8/go.mod h1:xOoGZrtUT+A5izWfHSJgl0gYZUE7lu7Z2XIS1vWG/QQ= +github.com/cometbft/cometbft v0.38.9 h1:cJBJBG0mPKz+sqelCi/hlfZjadZQGdDNnu6YQ1ZsUHQ= +github.com/cometbft/cometbft v0.38.9/go.mod h1:xOoGZrtUT+A5izWfHSJgl0gYZUE7lu7Z2XIS1vWG/QQ= github.com/cometbft/cometbft-db v0.12.0 h1:v77/z0VyfSU7k682IzZeZPFZrQAKiQwkqGN0QzAjMi0= github.com/cometbft/cometbft-db v0.12.0/go.mod h1:aX2NbCrjNVd2ZajYxt1BsiFf/Z+TQ2MN0VxdicheYuw= github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= From c2a1268f5945805ba552d5752a27c3ae41445bea Mon Sep 17 00:00:00 2001 From: Cosmos SDK <113218068+github-prbot@users.noreply.github.com> Date: Fri, 19 Jul 2024 16:29:21 +0200 Subject: [PATCH 08/50] chore: fix spelling errors (#20997) Co-authored-by: github-merge-queue <118344674+github-merge-queue@users.noreply.github.com> Co-authored-by: Julien Robert --- .github/.codespellignore | 3 ++- .github/pr_labeler.yml | 10 ++++++++++ server/v2/appmanager/appmanager.go | 2 +- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/.github/.codespellignore b/.github/.codespellignore index 301cd418a1b0..e1e8758d0c30 100644 --- a/.github/.codespellignore +++ b/.github/.codespellignore @@ -3,4 +3,5 @@ pullrequest keypair pastTime hasTables -Nam \ No newline at end of file +Nam +EyT \ No newline at end of file diff --git a/.github/pr_labeler.yml b/.github/pr_labeler.yml index 8b710d5fd983..328bf07902ff 100644 --- a/.github/pr_labeler.yml +++ b/.github/pr_labeler.yml @@ -74,6 +74,16 @@ - x/upgrade/**/* "C:x/epochs": - x/epochs/**/* +"C:server/v2": + - server/v2/**/* +"C:server/v2 stf": + - server/v2/stf/**/* +"C:server/v2 appmanager": + - server/v2/appmanager/**/* +"C:server/v2 cometbft": + - server/v2/cometbft/**/* +"C:server/v2 api": + - server/v2/api/**/* "Type: ADR": - docs/architecture/**/* "Type: Build": diff --git a/server/v2/appmanager/appmanager.go b/server/v2/appmanager/appmanager.go index 370103d0ddcc..d9c84c5035d7 100644 --- a/server/v2/appmanager/appmanager.go +++ b/server/v2/appmanager/appmanager.go @@ -81,7 +81,7 @@ func (a AppManager[T]) InitGenesis( err = genesisState.ApplyStateChanges(blockZeroStateChanges) if err != nil { - return nil, nil, fmt.Errorf("failed to apply blcok zero state changes to genesis state: %w", err) + return nil, nil, fmt.Errorf("failed to apply block zero state changes to genesis state: %w", err) } return blockResponse, genesisState, err From 023ed3558d661a7a7a8abd857ce27e63a3ce720e Mon Sep 17 00:00:00 2001 From: Tuan Tran Date: Fri, 19 Jul 2024 23:21:01 +0700 Subject: [PATCH 09/50] chore(docs): fix comments that do not start with the name of the exported element (#20999) --- store/dbadapter/store.go | 2 +- store/gaskv/store.go | 18 ++++++------ store/iavl/store.go | 18 ++++++------ store/internal/maps/maps.go | 4 +-- store/prefix/store.go | 26 ++++++++--------- store/rootmulti/proof.go | 2 ++ store/rootmulti/store.go | 2 +- store/snapshots/store.go | 2 +- store/snapshots/types/convert.go | 4 +-- store/streaming/abci/grpc.go | 2 +- store/transient/store.go | 8 +++--- store/types/codec.go | 3 +- store/types/store.go | 38 +++++++++++++------------ store/types/validity.go | 7 +++-- store/v2/db/prefixdb.go | 2 +- store/v2/internal/encoding/encoding.go | 10 +++---- store/v2/storage/pebbledb/comparator.go | 4 ++- store/v2/validation.go | 6 ++-- 18 files changed, 85 insertions(+), 73 deletions(-) diff --git a/store/dbadapter/store.go b/store/dbadapter/store.go index 369a173ec140..d69e4ebf1357 100644 --- a/store/dbadapter/store.go +++ b/store/dbadapter/store.go @@ -10,7 +10,7 @@ import ( "cosmossdk.io/store/types" ) -// Wrapper type for dbm.Db with implementation of KVStore +// Store is wrapper type for dbm.Db with implementation of KVStore type Store struct { dbm.DB } diff --git a/store/gaskv/store.go b/store/gaskv/store.go index e0f96af7151e..41242d49284b 100644 --- a/store/gaskv/store.go +++ b/store/gaskv/store.go @@ -26,12 +26,12 @@ func NewStore(parent types.KVStore, gasMeter types.GasMeter, gasConfig types.Gas return kvs } -// Implements Store. +// GetStoreType implements Store. func (gs *Store) GetStoreType() types.StoreType { return gs.parent.GetStoreType() } -// Implements KVStore. +// Get implements KVStore. func (gs *Store) Get(key []byte) (value []byte) { gs.gasMeter.ConsumeGas(gs.gasConfig.ReadCostFlat, types.GasReadCostFlatDesc) value = gs.parent.Get(key) @@ -43,7 +43,7 @@ func (gs *Store) Get(key []byte) (value []byte) { return value } -// Implements KVStore. +// Set implements KVStore. func (gs *Store) Set(key, value []byte) { types.AssertValidKey(key) types.AssertValidValue(value) @@ -54,13 +54,13 @@ func (gs *Store) Set(key, value []byte) { gs.parent.Set(key, value) } -// Implements KVStore. +// Has implements KVStore. func (gs *Store) Has(key []byte) bool { gs.gasMeter.ConsumeGas(gs.gasConfig.HasCost, types.GasHasDesc) return gs.parent.Has(key) } -// Implements KVStore. +// Delete implements KVStore. func (gs *Store) Delete(key []byte) { // charge gas to prevent certain attack vectors even though space is being freed gs.gasMeter.ConsumeGas(gs.gasConfig.DeleteCost, types.GasDeleteDesc) @@ -82,7 +82,7 @@ func (gs *Store) ReverseIterator(start, end []byte) types.Iterator { return gs.iterator(start, end, false) } -// Implements KVStore. +// CacheWrap implements KVStore. func (gs *Store) CacheWrap() types.CacheWrap { panic("cannot CacheWrap a GasKVStore") } @@ -120,12 +120,12 @@ func newGasIterator(gasMeter types.GasMeter, gasConfig types.GasConfig, parent t } } -// Implements Iterator. +// Domain implements Iterator. func (gi *gasIterator) Domain() (start, end []byte) { return gi.parent.Domain() } -// Implements Iterator. +// Valid implements Iterator. func (gi *gasIterator) Valid() bool { return gi.parent.Valid() } @@ -152,7 +152,7 @@ func (gi *gasIterator) Value() (value []byte) { return value } -// Implements Iterator. +// Close implements Iterator. func (gi *gasIterator) Close() error { return gi.parent.Close() } diff --git a/store/iavl/store.go b/store/iavl/store.go index 04d170b73ea6..8e1905b7a38b 100644 --- a/store/iavl/store.go +++ b/store/iavl/store.go @@ -179,12 +179,12 @@ func (st *Store) GetAllVersions() []int { return st.tree.AvailableVersions() } -// Implements Store. +// GetStoreType implements Store. func (st *Store) GetStoreType() types.StoreType { return types.StoreTypeIAVL } -// Implements Store. +// CacheWrap implements Store. func (st *Store) CacheWrap() types.CacheWrap { return cachekv.NewStore(st) } @@ -194,7 +194,7 @@ func (st *Store) CacheWrapWithTrace(w io.Writer, tc types.TraceContext) types.Ca return cachekv.NewStore(tracekv.NewStore(st, w, tc)) } -// Implements types.KVStore. +// Set implements types.KVStore. func (st *Store) Set(key, value []byte) { types.AssertValidKey(key) types.AssertValidValue(value) @@ -204,7 +204,7 @@ func (st *Store) Set(key, value []byte) { } } -// Implements types.KVStore. +// Get implements types.KVStore. func (st *Store) Get(key []byte) []byte { defer st.metrics.MeasureSince("store", "iavl", "get") value, err := st.tree.Get(key) @@ -214,7 +214,7 @@ func (st *Store) Get(key []byte) []byte { return value } -// Implements types.KVStore. +// Has implements types.KVStore. func (st *Store) Has(key []byte) (exists bool) { defer st.metrics.MeasureSince("store", "iavl", "has") has, err := st.tree.Has(key) @@ -224,7 +224,7 @@ func (st *Store) Has(key []byte) (exists bool) { return has } -// Implements types.KVStore. +// Delete implements types.KVStore. func (st *Store) Delete(key []byte) { defer st.metrics.MeasureSince("store", "iavl", "delete") _, _, err := st.tree.Remove(key) @@ -246,7 +246,7 @@ func (st *Store) LoadVersionForOverwriting(targetVersion int64) error { return st.tree.LoadVersionForOverwriting(targetVersion) } -// Implements types.KVStore. +// Iterator implements types.KVStore. func (st *Store) Iterator(start, end []byte) types.Iterator { iterator, err := st.tree.Iterator(start, end, true) if err != nil { @@ -255,7 +255,7 @@ func (st *Store) Iterator(start, end []byte) types.Iterator { return iterator } -// Implements types.KVStore. +// ReverseIterator implements types.KVStore. func (st *Store) ReverseIterator(start, end []byte) types.Iterator { iterator, err := st.tree.Iterator(start, end, false) if err != nil { @@ -270,7 +270,7 @@ func (st *Store) SetInitialVersion(version int64) { st.tree.SetInitialVersion(uint64(version)) } -// Exports the IAVL store at the given version, returning an iavl.Exporter for the tree. +// Export exports the IAVL store at the given version, returning an iavl.Exporter for the tree. func (st *Store) Export(version int64) (*iavl.Exporter, error) { istore, err := st.GetImmutable(version) if err != nil { diff --git a/store/internal/maps/maps.go b/store/internal/maps/maps.go index 40aa0b44d9f8..6db2be666cae 100644 --- a/store/internal/maps/maps.go +++ b/store/internal/maps/maps.go @@ -120,7 +120,7 @@ func (sm *simpleMap) Sort() { sm.sorted = true } -// Returns a copy of sorted KVPairs. +// KVPairs returns a copy of sorted KVPairs. // NOTE these contain the hashed key and value. func (sm *simpleMap) KVPairs() kv.Pairs { sm.Sort() @@ -134,7 +134,7 @@ func (sm *simpleMap) KVPairs() kv.Pairs { //---------------------------------------- -// A local extension to KVPair that can be hashed. +// KVPair is a local extension to KVPair that can be hashed. // Key and value are length prefixed and concatenated, // then hashed. type KVPair kv.Pair diff --git a/store/prefix/store.go b/store/prefix/store.go index 62f451fa430d..26b8b0344a79 100644 --- a/store/prefix/store.go +++ b/store/prefix/store.go @@ -42,12 +42,12 @@ func (s Store) key(key []byte) (res []byte) { return } -// Implements Store +// GetStoreType implements Store func (s Store) GetStoreType() types.StoreType { return s.parent.GetStoreType() } -// Implements CacheWrap +// CacheWrap implements CacheWrap func (s Store) CacheWrap() types.CacheWrap { return cachekv.NewStore(s) } @@ -57,30 +57,30 @@ func (s Store) CacheWrapWithTrace(w io.Writer, tc types.TraceContext) types.Cach return cachekv.NewStore(tracekv.NewStore(s, w, tc)) } -// Implements KVStore +// Get implements KVStore func (s Store) Get(key []byte) []byte { res := s.parent.Get(s.key(key)) return res } -// Implements KVStore +// Has implements KVStore func (s Store) Has(key []byte) bool { return s.parent.Has(s.key(key)) } -// Implements KVStore +// Set implements KVStore func (s Store) Set(key, value []byte) { types.AssertValidKey(key) types.AssertValidValue(value) s.parent.Set(s.key(key), value) } -// Implements KVStore +// Delete implements KVStore func (s Store) Delete(key []byte) { s.parent.Delete(s.key(key)) } -// Implements KVStore +// Iterator implements KVStore // Check https://github.com/cometbft/cometbft/blob/master/libs/db/prefix_db.go#L106 func (s Store) Iterator(start, end []byte) types.Iterator { newstart := cloneAppend(s.prefix, start) @@ -134,17 +134,17 @@ func newPrefixIterator(prefix, start, end []byte, parent types.Iterator) *prefix } } -// Implements Iterator +// Domain implements Iterator func (pi *prefixIterator) Domain() ([]byte, []byte) { return pi.start, pi.end } -// Implements Iterator +// Valid implements Iterator func (pi *prefixIterator) Valid() bool { return pi.valid && pi.iter.Valid() } -// Implements Iterator +// Next implements Iterator func (pi *prefixIterator) Next() { if !pi.valid { panic("prefixIterator invalid, cannot call Next()") @@ -156,7 +156,7 @@ func (pi *prefixIterator) Next() { } } -// Implements Iterator +// Key implements Iterator func (pi *prefixIterator) Key() (key []byte) { if !pi.valid { panic("prefixIterator invalid, cannot call Key()") @@ -168,7 +168,7 @@ func (pi *prefixIterator) Key() (key []byte) { return } -// Implements Iterator +// Value implements Iterator func (pi *prefixIterator) Value() []byte { if !pi.valid { panic("prefixIterator invalid, cannot call Value()") @@ -177,7 +177,7 @@ func (pi *prefixIterator) Value() []byte { return pi.iter.Value() } -// Implements Iterator +// Close implements Iterator func (pi *prefixIterator) Close() error { return pi.iter.Close() } diff --git a/store/rootmulti/proof.go b/store/rootmulti/proof.go index 78217a1600bc..5f1503be4b93 100644 --- a/store/rootmulti/proof.go +++ b/store/rootmulti/proof.go @@ -17,6 +17,8 @@ func RequireProof(subpath string) bool { //----------------------------------------------------------------------------- +// DefaultProofRuntime returns a new ProofRuntime with default op decoders registered. +// It registers decoders for IAVL commitment and Simple Merkle commitment proof operations. // XXX: This should be managed by the rootMultiStore which may want to register // more proof ops? func DefaultProofRuntime() (prt *merkle.ProofRuntime) { diff --git a/store/rootmulti/store.go b/store/rootmulti/store.go index 1be58ea36dc1..ab6402447f71 100644 --- a/store/rootmulti/store.go +++ b/store/rootmulti/store.go @@ -725,7 +725,7 @@ func (rs *Store) PruneStores(pruningHeight int64) (err error) { return nil } -// getStoreByName performs a lookup of a StoreKey given a store name typically +// GetStoreByName performs a lookup of a StoreKey given a store name typically // provided in a path. The StoreKey is then used to perform a lookup and return // a Store. If the Store is wrapped in an inter-block cache, it will be unwrapped // prior to being returned. If the StoreKey does not exist, nil is returned. diff --git a/store/snapshots/store.go b/store/snapshots/store.go index aa593f5bac61..c58461a68b4f 100644 --- a/store/snapshots/store.go +++ b/store/snapshots/store.go @@ -92,7 +92,7 @@ func (s *Store) Get(height uint64, format uint32) (*types.Snapshot, error) { return snapshot, nil } -// Get fetches the latest snapshot from the database, if any. +// GetLatest fetches the latest snapshot from the database, if any. func (s *Store) GetLatest() (*types.Snapshot, error) { iter, err := s.db.ReverseIterator(encodeKey(0, 0), encodeKey(uint64(math.MaxUint64), math.MaxUint32)) if err != nil { diff --git a/store/snapshots/types/convert.go b/store/snapshots/types/convert.go index f326878757dd..a5ed10929cb7 100644 --- a/store/snapshots/types/convert.go +++ b/store/snapshots/types/convert.go @@ -7,7 +7,7 @@ import ( "cosmossdk.io/errors" ) -// Converts an ABCI snapshot to a snapshot. Mainly to decode the SDK metadata. +// SnapshotFromABCI converts an ABCI snapshot to a snapshot. Mainly to decode the SDK metadata. func SnapshotFromABCI(in *abci.Snapshot) (Snapshot, error) { snapshot := Snapshot{ Height: in.Height, @@ -22,7 +22,7 @@ func SnapshotFromABCI(in *abci.Snapshot) (Snapshot, error) { return snapshot, nil } -// Converts a Snapshot to its ABCI representation. Mainly to encode the SDK metadata. +// ToABCI converts a Snapshot to its ABCI representation. Mainly to encode the SDK metadata. func (s Snapshot) ToABCI() (abci.Snapshot, error) { out := abci.Snapshot{ Height: s.Height, diff --git a/store/streaming/abci/grpc.go b/store/streaming/abci/grpc.go index b838a153be17..89e1c01c2b26 100644 --- a/store/streaming/abci/grpc.go +++ b/store/streaming/abci/grpc.go @@ -17,7 +17,7 @@ type GRPCClient struct { client ABCIListenerServiceClient } -// ListenEndBlock listens to end block request and responses. +// ListenFinalizeBlock listens to end block request and responses. // In addition, it retrieves a types.Context from a context.Context instance. // It panics if a types.Context was not properly attached. // When the node is configured to stop on listening errors, diff --git a/store/transient/store.go b/store/transient/store.go index 2794d3d9a119..d72a72476efc 100644 --- a/store/transient/store.go +++ b/store/transient/store.go @@ -18,13 +18,13 @@ type Store struct { dbadapter.Store } -// Constructs new MemDB adapter +// NewStore constructs new MemDB adapter func NewStore() *Store { return &Store{Store: dbadapter.Store{DB: dbm.NewMemDB()}} } -// Implements CommitStore // Commit cleans up Store. +// Implements CommitStore func (ts *Store) Commit() (id types.CommitID) { ts.Store = dbadapter.Store{DB: dbm.NewMemDB()} return @@ -38,7 +38,7 @@ func (ts *Store) GetPruning() pruningtypes.PruningOptions { return pruningtypes.NewPruningOptions(pruningtypes.PruningUndefined) } -// Implements CommitStore +// LastCommitID implements CommitStore func (ts *Store) LastCommitID() types.CommitID { return types.CommitID{} } @@ -47,7 +47,7 @@ func (ts *Store) WorkingHash() []byte { return []byte{} } -// Implements Store. +// GetStoreType implements Store. func (ts *Store) GetStoreType() types.StoreType { return types.StoreTypeTransient } diff --git a/store/types/codec.go b/store/types/codec.go index 4a5f424873f0..3b5203747ce5 100644 --- a/store/types/codec.go +++ b/store/types/codec.go @@ -19,12 +19,13 @@ type Codec interface { // in the value pointed to by v. Unmarshal(bz []byte, ptr proto.Message) error - // Unmarshal parses the data encoded with UnmarshalLengthPrefixed method and stores + // UnmarshalLengthPrefixed parses the data encoded with UnmarshalLengthPrefixed method and stores // the result in the value pointed to by v. UnmarshalLengthPrefixed(bz []byte, ptr proto.Message) error } // ============= TestCodec ============= + // TestCodec defines a codec that utilizes Protobuf for both binary and JSON // encoding. type TestCodec struct{} diff --git a/store/types/store.go b/store/types/store.go index ea9667691d38..7846876eeb6d 100644 --- a/store/types/store.go +++ b/store/types/store.go @@ -17,7 +17,7 @@ type Store interface { CacheWrapper } -// something that can persist to disk +// Committer is something that can persist to disk type Committer interface { Commit() CommitID LastCommitID() CommitID @@ -37,6 +37,8 @@ type PausablePruner interface { PausePruning(bool) } +// CommitStore represents a store that can be committed and provides basic store operations. +// It combines the functionality of Committer and Store interfaces. // Stores of MultiStore must implement CommitStore. type CommitStore interface { Committer @@ -131,7 +133,7 @@ func (s *StoreUpgrades) RenamedFrom(key string) string { type MultiStore interface { Store - // Branches MultiStore into a cached storage object. + // CacheMultiStore branches MultiStore into a cached storage object. // NOTE: Caller should probably not call .Write() on each, but // call CacheMultiStore.Write(). CacheMultiStore() CacheMultiStore @@ -140,7 +142,7 @@ type MultiStore interface { // each stored is loaded at a specific version (height). CacheMultiStoreWithVersion(version int64) (CacheMultiStore, error) - // Convenience for fetching substores. + // GetStore is convenience for fetching substores. // If the store does not exist, panics. GetStore(StoreKey) Store GetKVStore(StoreKey) KVStore @@ -162,7 +164,7 @@ type MultiStore interface { LatestVersion() int64 } -// From MultiStore.CacheMultiStore().... +// CacheMultiStore is from MultiStore.CacheMultiStore().... type CacheMultiStore interface { MultiStore Write() // Writes operations to underlying KVStore @@ -174,17 +176,17 @@ type CommitMultiStore interface { MultiStore snapshottypes.Snapshotter - // Mount a store of type using the given db. + // MountStoreWithDB mount a store of type using the given db. // If db == nil, the new store will use the CommitMultiStore db. MountStoreWithDB(key StoreKey, typ StoreType, db dbm.DB) - // Panics on a nil key. + // GetCommitStore panics on a nil key. GetCommitStore(key StoreKey) CommitStore - // Panics on a nil key. + // GetCommitKVStore panics on a nil key. GetCommitKVStore(key StoreKey) CommitKVStore - // Load the latest persisted version. Called once after all calls to + // LoadLatestVersion load the latest persisted version. Called once after all calls to // Mount*Store() are complete. LoadLatestVersion() error @@ -198,13 +200,13 @@ type CommitMultiStore interface { // in order to handle breaking formats in migrations LoadVersionAndUpgrade(ver int64, upgrades *StoreUpgrades) error - // Load a specific persisted version. When you load an old version, or when + // LoadVersion load a specific persisted version. When you load an old version, or when // the last commit attempt didn't complete, the next commit after loading // must be idempotent (return the same commit id). Otherwise the behavior is // undefined. LoadVersion(ver int64) error - // Set an inter-block (persistent) cache that maintains a mapping from + // SetInterBlockCache set an inter-block (persistent) cache that maintains a mapping from // StoreKeys to CommitKVStores. SetInterBlockCache(MultiStorePersistentCache) @@ -265,7 +267,7 @@ type KVStore interface { // Exceptionally allowed for cachekv.Store, safe to write in the modules. Iterator(start, end []byte) Iterator - // Iterator over a domain of keys in descending order. End is exclusive. + // ReverseIterator iterates over a domain of keys in descending order. End is exclusive. // Start must be less than end, or the Iterator is invalid. // Iterator must be closed by caller. // CONTRACT: No writes may happen within a domain while an iterator exists over it. @@ -282,7 +284,7 @@ type Iterator = dbm.Iterator type CacheKVStore interface { KVStore - // Writes operations to underlying KVStore + // Write writes operations to underlying KVStore Write() } @@ -329,7 +331,7 @@ func (cid CommitID) String() string { //---------------------------------------- // Store types -// kind of store +// StoreType is kind of store type StoreType int const ( @@ -425,7 +427,7 @@ type TransientStoreKey struct { name string } -// Constructs new TransientStoreKey +// NewTransientStoreKey constructs new TransientStoreKey // Must return a pointer according to the ocap principle func NewTransientStoreKey(name string) *TransientStoreKey { return &TransientStoreKey{ @@ -433,12 +435,12 @@ func NewTransientStoreKey(name string) *TransientStoreKey { } } -// Implements StoreKey +// Name implements StoreKey func (key *TransientStoreKey) Name() string { return key.name } -// Implements StoreKey +// String implements StoreKey func (key *TransientStoreKey) String() string { return fmt.Sprintf("TransientStoreKey{%p, %s}", key, key.name) } @@ -494,11 +496,11 @@ func (tc TraceContext) Merge(newTc TraceContext) TraceContext { // MultiStorePersistentCache defines an interface which provides inter-block // (persistent) caching capabilities for multiple CommitKVStores based on StoreKeys. type MultiStorePersistentCache interface { - // Wrap and return the provided CommitKVStore with an inter-block (persistent) + // GetStoreCache wrap and return the provided CommitKVStore with an inter-block (persistent) // cache. GetStoreCache(key StoreKey, store CommitKVStore) CommitKVStore - // Return the underlying CommitKVStore for a StoreKey. + // Unwrap return the underlying CommitKVStore for a StoreKey. Unwrap(key StoreKey) CommitKVStore // Reset the entire set of internal caches. diff --git a/store/types/validity.go b/store/types/validity.go index a1fbaba999c7..73b15bdacc52 100644 --- a/store/types/validity.go +++ b/store/types/validity.go @@ -1,9 +1,12 @@ package types var ( - // 128K - 1 + // MaxKeyLength is the maximum allowed length for a key in bytes. + // It is set to 128K - 1 (131,071 bytes). MaxKeyLength = (1 << 17) - 1 - // 2G - 1 + + // MaxValueLength is the maximum allowed length for a value in bytes. + // It is set to 2G - 1 (2,147,483,647 bytes). MaxValueLength = (1 << 31) - 1 ) diff --git a/store/v2/db/prefixdb.go b/store/v2/db/prefixdb.go index 643f2e95f7a1..fc13bbb5af0a 100644 --- a/store/v2/db/prefixdb.go +++ b/store/v2/db/prefixdb.go @@ -247,7 +247,7 @@ func (itr *prefixDBIterator) Next() { } } -// Next implements Iterator. +// Key implements Iterator. func (itr *prefixDBIterator) Key() []byte { itr.assertIsValid() key := itr.source.Key() diff --git a/store/v2/internal/encoding/encoding.go b/store/v2/internal/encoding/encoding.go index 40d558da3871..b73b923f11d0 100644 --- a/store/v2/internal/encoding/encoding.go +++ b/store/v2/internal/encoding/encoding.go @@ -28,7 +28,7 @@ var uvarintPool = &sync.Pool{ }, } -// decodeBytes decodes a varint length-prefixed byte slice, returning it along with the number +// DecodeBytes decodes a varint length-prefixed byte slice, returning it along with the number // of input bytes read. // Assumes bz will not be mutated. func DecodeBytes(bz []byte) ([]byte, int, error) { @@ -55,7 +55,7 @@ func DecodeBytes(bz []byte) ([]byte, int, error) { return bz[n:end], end, nil } -// decodeUvarint decodes a varint-encoded unsigned integer from a byte slice, returning it and the +// DecodeUvarint decodes a varint-encoded unsigned integer from a byte slice, returning it and the // number of bytes decoded. func DecodeUvarint(bz []byte) (uint64, int, error) { u, n := binary.Uvarint(bz) @@ -71,7 +71,7 @@ func DecodeUvarint(bz []byte) (uint64, int, error) { return u, n, nil } -// decodeVarint decodes a varint-encoded integer from a byte slice, returning it and the number of +// DecodeVarint decodes a varint-encoded integer from a byte slice, returning it and the number of // bytes decoded. func DecodeVarint(bz []byte) (int64, int, error) { i, n := binary.Varint(bz) @@ -96,7 +96,7 @@ func EncodeBytes(w io.Writer, bz []byte) error { return err } -// encodeBytesSlice length-prefixes the byte slice and returns it. +// EncodeBytesSlice length-prefixes the byte slice and returns it. func EncodeBytesSlice(bz []byte) ([]byte, error) { buf := bufPool.Get().(*bytes.Buffer) buf.Reset() @@ -110,7 +110,7 @@ func EncodeBytesSlice(bz []byte) ([]byte, error) { return bytesCopy, err } -// encodeBytesSize returns the byte size of the given slice including length-prefixing. +// EncodeBytesSize returns the byte size of the given slice including length-prefixing. func EncodeBytesSize(bz []byte) int { return EncodeUvarintSize(uint64(len(bz))) + len(bz) } diff --git a/store/v2/storage/pebbledb/comparator.go b/store/v2/storage/pebbledb/comparator.go index 08b360e6c079..337ff7698d84 100644 --- a/store/v2/storage/pebbledb/comparator.go +++ b/store/v2/storage/pebbledb/comparator.go @@ -202,7 +202,9 @@ func MVCCKeyCompare(a, b []byte) int { return bytes.Compare(aTS, bTS) } -// \x00[]<#version-bytes> +// MVCCEncode encodes a key and version into an MVCC format. +// The format is: \x00[]<#version-bytes> +// If the version is 0, only the key and a null byte are encoded. func MVCCEncode(key []byte, version uint64) (dst []byte) { dst = append(dst, key...) dst = append(dst, 0) diff --git a/store/v2/validation.go b/store/v2/validation.go index e1bfcfa78b88..a495f83b781c 100644 --- a/store/v2/validation.go +++ b/store/v2/validation.go @@ -1,10 +1,12 @@ package store var ( - // 128K - 1 + // MaxKeyLength is the maximum allowed length for a key in bytes. + // It is set to 128K - 1 (131,071 bytes). MaxKeyLength = (1 << 17) - 1 - // 2G - 1 + // MaxValueLength is the maximum allowed length for a value in bytes. + // It is set to 2G - 1 (2,147,483,647 bytes). MaxValueLength = (1 << 31) - 1 ) From b55138497bfd1c972d48f5df96f2783cbcf1fb48 Mon Sep 17 00:00:00 2001 From: Jeeyong Um Date: Sat, 20 Jul 2024 01:25:06 +0900 Subject: [PATCH 10/50] docs: Fix typos in RFC Creation Process (#20998) --- docs/rfc/PROCESS.md | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/docs/rfc/PROCESS.md b/docs/rfc/PROCESS.md index 9517868b5568..a4946cb2a218 100644 --- a/docs/rfc/PROCESS.md +++ b/docs/rfc/PROCESS.md @@ -1,34 +1,34 @@ # RFC Creation Process 1. Copy the `rfc-template.md` file. Use the following filename pattern: `rfc-next_number-title.md` -2. Create a draft Pull Request if you want to get an early feedback. -3. Make sure the context and a solution is clear and well documented. -4. Add an entry to a list in the [README](./README.md) file. -5. Create a Pull Request to propose a new ADR. +2. Create a draft Pull Request if you want to get early feedback. +3. Make sure the context and solution are clear and well-documented. +4. Add an entry to the list in the [README](./README.md) file. +5. Create a Pull Request to propose a new RFC. ## What is an RFC? -An RFC is a sort of async whiteboarding session. It is meant to replace the need for a distributed team to come together to make a decision. Currently, the Cosmos SDK team and contributors are distributed around the world. The team conducts working groups to have a synchronous discussion and an RFC can be used to capture the discussion for a wider audience to better understand the changes that are coming to the software. +An RFC is a sort of async whiteboarding session. It is meant to replace the need for a distributed team to come together to decide. Currently, the Cosmos SDK team and contributors are distributed around the world. The team conducts working groups to have a synchronous discussion, and an RFC can be used to capture the discussion for a wider audience to better understand the changes that are coming to the software. -The main difference the Cosmos SDK is defining as a differentiation between RFC and ADRs is that one is to come to consensus and circulate information about a potential change or feature. An ADR is used if there is already consensus on a feature or change and there is not a need to articulate the change coming to the software. An ADR will articulate the changes and have a lower amount of communication . +The main difference the Cosmos SDK defines between RFCs and ADRs is that an RFC is to come to consensus and circulate information about a potential change or feature. An ADR is used if there is already consensus on a feature or change and there is no need to articulate the change coming to the software. An ADR will articulate the changes and require less communication. ## RFC life cycle -RFC creation is an **iterative** process. An RFC is meant as a distributed collaboration session, it may have many comments and is usually the bi-product of no working group or synchronous communication +RFC creation is an **iterative** process. An RFC is meant as a distributed collaboration session, it may have many comments and is usually the by-product of no working group or synchronous communication. -1. Proposals could start with a new GitHub Issue, be a result of existing Issues or a discussion. +1. Proposals could start with a new GitHub Issue, be a result of existing Issues or a discussion. 2. An RFC doesn't have to arrive to `main` with an _accepted_ status in a single PR. If the motivation is clear and the solution is sound, we SHOULD be able to merge it and keep a _proposed_ status. It's preferable to have an iterative approach rather than long, not merged Pull Requests. 3. If a _proposed_ RFC is merged, then it should clearly document outstanding issues either in the RFC document notes or in a GitHub Issue. -4. The PR SHOULD always be merged. In the case of a faulty RFC, we still prefer to merge it with a _rejected_ status. The only time the RFC SHOULD NOT be merged is if the author abandons it. +4. The PR SHOULD always be merged. In the case of a faulty RFC, we still prefer to merge it with a _rejected_ status. The only time the RFC SHOULD NOT be merged is if the author abandons it. 5. Merged RFCs SHOULD NOT be pruned. -6. If there is consensus and enough feedback then the RFC can be accepted. +6. If there is consensus and enough feedback then the RFC can be accepted. -> Note: An RFC is written when there is no working group or team session on the problem. RFC's are meant as a distributed white boarding session. If there is a working group on the proposal there is no need to have an RFC as there is synchronous whiteboarding going on. +> Note: An RFC is written when there is no working group or team session on the problem. RFCs are meant as a distributed whiteboarding session. If there is a working group on the proposal, there is no need to have an RFC as there is synchronous whiteboarding going on. ### RFC status @@ -41,22 +41,22 @@ Status has two components: #### Consensus Status ```text -DRAFT -> PROPOSED -> LAST CALL yyyy-mm-dd -> ACCEPTED | REJECTED -> SUPERSEDED by ADR-xxx +DRAFT -> PROPOSED -> LAST CALL yyyy-mm-dd -> ACCEPTED | REJECTED -> SUPERSEDED by RFC-xxx \ | \ | v v ABANDONED ``` -* `DRAFT`: [optional] an ADR which is work in progress, not being ready for a general review. This is to present an early work and get an early feedback in a Draft Pull Request form. -* `PROPOSED`: an ADR covering a full solution architecture and still in the review - project stakeholders haven't reached an agreed yet. -* `LAST CALL `: [optional] clear notify that we are close to accept updates. Changing a status to `LAST CALL` means that social consensus (of Cosmos SDK maintainers) has been reached and we still want to give it a time to let the community react or analyze. -* `ACCEPTED`: ADR which will represent a currently implemented or to be implemented architecture design. -* `REJECTED`: ADR can go from PROPOSED or ACCEPTED to rejected if the consensus among project stakeholders will decide so. -* `SUPERSEDED by ADR-xxx`: ADR which has been superseded by a new ADR. -* `ABANDONED`: the ADR is no longer pursued by the original authors. +* `DRAFT`: [optional] an RFC which is work in progress, not being ready for a general review. This is to present early work and get early feedback in a Draft Pull Request form. +* `PROPOSED`: an RFC covering a full solution architecture and still in review - project stakeholders haven't reached an agreement yet. +* `LAST CALL `: [optional] clearly notify that we are close to accepting updates. Changing a status to `LAST CALL` means that social consensus (of Cosmos SDK maintainers) has been reached, and we still want to give it time to let the community react or analyze. +* `ACCEPTED`: RFC which will represent a currently implemented or to be implemented architecture design. +* `REJECTED`: RFC can go from PROPOSED or ACCEPTED to rejected if the consensus among project stakeholders decides so. +* `SUPERSEDED by RFC-xxx`: RFC which has been superseded by a new RFC. +* `ABANDONED`: the RFC is no longer pursued by the original authors. ## Language used in RFC * The background/goal should be written in the present tense. -* Avoid using a first, personal form. +* Avoid using a first-person form. From 748352ef935d99077988263cf0eca0b0b9953243 Mon Sep 17 00:00:00 2001 From: Julien Robert Date: Fri, 19 Jul 2024 22:16:42 +0200 Subject: [PATCH 11/50] chore: prepare depinject 1.0.0 (#21001) --- depinject/CHANGELOG.md | 5 +- depinject/appconfig/config.go | 10 +- simapp/app_config.go | 7 + simapp/upgrades.go | 3 + testutil/x/counter/autocli.go | 34 ++ testutil/x/counter/depinject.go | 6 +- .../cosmos/counter/module/v1/module.proto | 2 + testutil/x/counter/types/module.pb.go | 322 ++++++++++++++++++ 8 files changed, 380 insertions(+), 9 deletions(-) create mode 100644 testutil/x/counter/autocli.go create mode 100644 testutil/x/counter/types/module.pb.go diff --git a/depinject/CHANGELOG.md b/depinject/CHANGELOG.md index f386bd51196d..4b308e63a3e9 100644 --- a/depinject/CHANGELOG.md +++ b/depinject/CHANGELOG.md @@ -22,9 +22,10 @@ Each entry must include the Github issue reference in the following format: ## [Unreleased] -### Features +## 1.0.0 -- [#20540](https://github.com/cosmos/cosmos-sdk/pull/20540) add support for defining `appconfig` module configuration types using `github.com/cosmos/gogoproto/proto` in addition to `google.golang.org/protobuf` so that users can use gogo proto across their stack. +* [#20540](https://github.com/cosmos/cosmos-sdk/pull/20540) Add support for defining `appconfig` module configuration types using `github.com/cosmos/gogoproto/proto` in addition to `google.golang.org/protobuf` so that users can use gogo proto across their stack. +* Move `cosmossdk.io/core/appconfig` to `cosmossdk.io/depinject/appconfig`. ## 1.0.0-alpha.x diff --git a/depinject/appconfig/config.go b/depinject/appconfig/config.go index a63799b1a36a..10e1d037386d 100644 --- a/depinject/appconfig/config.go +++ b/depinject/appconfig/config.go @@ -5,7 +5,6 @@ import ( "reflect" "strings" - "github.com/cosmos/cosmos-proto/anyutil" gogoproto "github.com/cosmos/gogoproto/proto" "google.golang.org/protobuf/encoding/protojson" protov2 "google.golang.org/protobuf/proto" @@ -52,13 +51,16 @@ func LoadYAML(bz []byte) depinject.Config { } // WrapAny marshals a proto message into a proto Any instance -func WrapAny(config protoreflect.ProtoMessage) *anypb.Any { - cfg, err := anyutil.New(config) +func WrapAny(config gogoproto.Message) *anypb.Any { + pbz, err := gogoproto.Marshal(config) if err != nil { panic(err) } - return cfg + return &anypb.Any{ + TypeUrl: "/" + gogoproto.MessageName(config), + Value: pbz, + } } // Compose composes an app config into a container option by resolving diff --git a/simapp/app_config.go b/simapp/app_config.go index f7f924825b05..4eb39f1766c7 100644 --- a/simapp/app_config.go +++ b/simapp/app_config.go @@ -69,6 +69,8 @@ import ( upgradetypes "cosmossdk.io/x/upgrade/types" "github.com/cosmos/cosmos-sdk/runtime" + _ "github.com/cosmos/cosmos-sdk/testutil/x/counter" // import for side-effects + countertypes "github.com/cosmos/cosmos-sdk/testutil/x/counter/types" genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types" ) @@ -279,6 +281,11 @@ var ( Name: epochstypes.ModuleName, Config: appconfig.WrapAny(&epochsmodulev1.Module{}), }, + // This module is used for testing the depinject gogo x pulsar module registration. + { + Name: countertypes.ModuleName, + Config: appconfig.WrapAny(&countertypes.Module{}), + }, }, }) ) diff --git a/simapp/upgrades.go b/simapp/upgrades.go index 7ff7377840d8..d8b1852c7289 100644 --- a/simapp/upgrades.go +++ b/simapp/upgrades.go @@ -10,6 +10,8 @@ import ( epochstypes "cosmossdk.io/x/epochs/types" protocolpooltypes "cosmossdk.io/x/protocolpool/types" upgradetypes "cosmossdk.io/x/upgrade/types" + + countertypes "github.com/cosmos/cosmos-sdk/testutil/x/counter/types" ) // UpgradeName defines the on-chain upgrade name for the sample SimApp upgrade @@ -45,6 +47,7 @@ func (app SimApp) RegisterUpgradeHandlers() { accounts.StoreKey, protocolpooltypes.StoreKey, epochstypes.StoreKey, + countertypes.StoreKey, // This module is used for testing purposes only. }, Deleted: []string{"crisis"}, // The SDK discontinued the crisis module in v0.52.0 } diff --git a/testutil/x/counter/autocli.go b/testutil/x/counter/autocli.go new file mode 100644 index 000000000000..2067df6b81d5 --- /dev/null +++ b/testutil/x/counter/autocli.go @@ -0,0 +1,34 @@ +package counter + +import ( + autocliv1 "cosmossdk.io/api/cosmos/autocli/v1" + counterv1 "cosmossdk.io/api/cosmos/counter/v1" +) + +// AutoCLIOptions implements the autocli.HasAutoCLIConfig interface. +func (am AppModule) AutoCLIOptions() *autocliv1.ModuleOptions { + return &autocliv1.ModuleOptions{ + Query: &autocliv1.ServiceCommandDescriptor{ + Service: counterv1.Query_ServiceDesc.ServiceName, + RpcCommandOptions: []*autocliv1.RpcCommandOptions{ + { + RpcMethod: "GetCount", + Use: "count", + Short: "Query the current counter value", + }, + }, + }, + Tx: &autocliv1.ServiceCommandDescriptor{ + Service: counterv1.Msg_ServiceDesc.ServiceName, + RpcCommandOptions: []*autocliv1.RpcCommandOptions{ + { + RpcMethod: "IncreaseCount", + Use: "increase-count [count]", + Alias: []string{"increase-counter", "increase", "inc", "bump"}, + Short: "Increase the counter by the specified amount", + PositionalArgs: []*autocliv1.PositionalArgDescriptor{{ProtoField: "count"}}, + }, + }, + }, + } +} diff --git a/testutil/x/counter/depinject.go b/testutil/x/counter/depinject.go index fcb8df1e3c2d..b529d7f54297 100644 --- a/testutil/x/counter/depinject.go +++ b/testutil/x/counter/depinject.go @@ -1,12 +1,12 @@ package counter import ( - modulev1 "cosmossdk.io/api/cosmos/counter/module/v1" "cosmossdk.io/core/appmodule" "cosmossdk.io/depinject" "cosmossdk.io/depinject/appconfig" "github.com/cosmos/cosmos-sdk/testutil/x/counter/keeper" + "github.com/cosmos/cosmos-sdk/testutil/x/counter/types" ) var _ depinject.OnePerModuleType = AppModule{} @@ -16,7 +16,7 @@ func (am AppModule) IsOnePerModuleType() {} func init() { appconfig.RegisterModule( - &modulev1.Module{}, + &types.Module{}, appconfig.Provide(ProvideModule), ) } @@ -24,7 +24,7 @@ func init() { type ModuleInputs struct { depinject.In - Config *modulev1.Module + Config *types.Module Environment appmodule.Environment } diff --git a/testutil/x/counter/proto/cosmos/counter/module/v1/module.proto b/testutil/x/counter/proto/cosmos/counter/module/v1/module.proto index f4be1da83c4a..7c0fa4055d11 100644 --- a/testutil/x/counter/proto/cosmos/counter/module/v1/module.proto +++ b/testutil/x/counter/proto/cosmos/counter/module/v1/module.proto @@ -4,6 +4,8 @@ package cosmos.counter.module.v1; import "cosmos/app/v1alpha1/module.proto"; +option go_package = "github.com/cosmos/cosmos-sdk/testutil/x/counter/types"; + // Module is the config object of the counter module. message Module { option (cosmos.app.v1alpha1.module) = { diff --git a/testutil/x/counter/types/module.pb.go b/testutil/x/counter/types/module.pb.go new file mode 100644 index 000000000000..37b734e319bc --- /dev/null +++ b/testutil/x/counter/types/module.pb.go @@ -0,0 +1,322 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: cosmos/counter/module/v1/module.proto + +package types + +import ( + _ "cosmossdk.io/depinject/appconfig/v1alpha1" + fmt "fmt" + proto "github.com/cosmos/gogoproto/proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// Module is the config object of the counter module. +type Module struct { + // authority defines the custom module authority. If not set, defaults to the governance module. + Authority string `protobuf:"bytes,1,opt,name=authority,proto3" json:"authority,omitempty"` +} + +func (m *Module) Reset() { *m = Module{} } +func (m *Module) String() string { return proto.CompactTextString(m) } +func (*Module) ProtoMessage() {} +func (*Module) Descriptor() ([]byte, []int) { + return fileDescriptor_917f5b05718fd5a3, []int{0} +} +func (m *Module) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Module) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Module.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *Module) XXX_Merge(src proto.Message) { + xxx_messageInfo_Module.Merge(m, src) +} +func (m *Module) XXX_Size() int { + return m.Size() +} +func (m *Module) XXX_DiscardUnknown() { + xxx_messageInfo_Module.DiscardUnknown(m) +} + +var xxx_messageInfo_Module proto.InternalMessageInfo + +func (m *Module) GetAuthority() string { + if m != nil { + return m.Authority + } + return "" +} + +func init() { + proto.RegisterType((*Module)(nil), "cosmos.counter.module.v1.Module") +} + +func init() { + proto.RegisterFile("cosmos/counter/module/v1/module.proto", fileDescriptor_917f5b05718fd5a3) +} + +var fileDescriptor_917f5b05718fd5a3 = []byte{ + // 201 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0x4d, 0xce, 0x2f, 0xce, + 0xcd, 0x2f, 0xd6, 0x4f, 0xce, 0x2f, 0xcd, 0x2b, 0x49, 0x2d, 0xd2, 0xcf, 0xcd, 0x4f, 0x29, 0xcd, + 0x49, 0xd5, 0x2f, 0x33, 0x84, 0xb2, 0xf4, 0x0a, 0x8a, 0xf2, 0x4b, 0xf2, 0x85, 0x24, 0x20, 0xca, + 0xf4, 0xa0, 0xca, 0xf4, 0xa0, 0x92, 0x65, 0x86, 0x52, 0x0a, 0x50, 0x03, 0x12, 0x0b, 0x0a, 0xf4, + 0xcb, 0x0c, 0x13, 0x73, 0x0a, 0x32, 0x12, 0x51, 0xf5, 0x2a, 0xc5, 0x73, 0xb1, 0xf9, 0x82, 0xf9, + 0x42, 0x32, 0x5c, 0x9c, 0x89, 0xa5, 0x25, 0x19, 0xf9, 0x45, 0x99, 0x25, 0x95, 0x12, 0x8c, 0x0a, + 0x8c, 0x1a, 0x9c, 0x41, 0x08, 0x01, 0x2b, 0xf3, 0x5d, 0x07, 0xa6, 0xdd, 0x62, 0x34, 0xe4, 0xd2, + 0x4f, 0xcf, 0x2c, 0xc9, 0x28, 0x4d, 0xd2, 0x4b, 0xce, 0xcf, 0xd5, 0x87, 0xbb, 0x0e, 0x44, 0xe9, + 0x16, 0xa7, 0x64, 0xeb, 0x97, 0xa4, 0x16, 0x97, 0x94, 0x96, 0x64, 0xe6, 0xe8, 0x57, 0xc0, 0xdc, + 0xec, 0xe4, 0x7f, 0xe2, 0x91, 0x1c, 0xe3, 0x85, 0x47, 0x72, 0x8c, 0x0f, 0x1e, 0xc9, 0x31, 0x4e, + 0x78, 0x2c, 0xc7, 0x70, 0xe1, 0xb1, 0x1c, 0xc3, 0x8d, 0xc7, 0x72, 0x0c, 0x51, 0xa6, 0x24, 0x1a, + 0xa5, 0x5f, 0x52, 0x59, 0x90, 0x5a, 0x9c, 0xc4, 0x06, 0x76, 0xb8, 0x31, 0x20, 0x00, 0x00, 0xff, + 0xff, 0x76, 0xab, 0xc7, 0x18, 0x1d, 0x01, 0x00, 0x00, +} + +func (m *Module) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *Module) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Module) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Authority) > 0 { + i -= len(m.Authority) + copy(dAtA[i:], m.Authority) + i = encodeVarintModule(dAtA, i, uint64(len(m.Authority))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintModule(dAtA []byte, offset int, v uint64) int { + offset -= sovModule(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *Module) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Authority) + if l > 0 { + n += 1 + l + sovModule(uint64(l)) + } + return n +} + +func sovModule(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozModule(x uint64) (n int) { + return sovModule(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *Module) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowModule + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: Module: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Module: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Authority", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowModule + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthModule + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthModule + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Authority = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipModule(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthModule + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipModule(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowModule + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowModule + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowModule + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthModule + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupModule + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthModule + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthModule = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowModule = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupModule = fmt.Errorf("proto: unexpected end of group") +) From e22890b11f5262c7e879b87f7d1cfb74bf6c5935 Mon Sep 17 00:00:00 2001 From: yukionfire Date: Sun, 21 Jul 2024 17:53:48 +0800 Subject: [PATCH 12/50] chore(x/staking,x/upgrade): replace `fmt.Errorf` without parameters with `errors.New` (#21004) --- x/params/types/common_test.go | 2 +- x/protocolpool/types/genesis.go | 22 +++++++++++----------- x/simulation/simulate.go | 3 ++- x/staking/keeper/delegation.go | 2 +- x/staking/keeper/slash.go | 4 ++-- x/staking/keeper/val_state_change.go | 5 +++-- x/staking/keeper/validator.go | 2 +- x/staking/types/params.go | 2 +- x/upgrade/keeper/keeper.go | 2 +- x/upgrade/keeper/migrations.go | 3 ++- 10 files changed, 25 insertions(+), 22 deletions(-) diff --git a/x/params/types/common_test.go b/x/params/types/common_test.go index 9fd9b1a535af..bd1d653c8650 100644 --- a/x/params/types/common_test.go +++ b/x/params/types/common_test.go @@ -39,7 +39,7 @@ func validateUnbondingTime(i interface{}) error { } if v < (24 * time.Hour) { - return fmt.Errorf("unbonding time must be at least one day") + return errors.New("unbonding time must be at least one day") } return nil diff --git a/x/protocolpool/types/genesis.go b/x/protocolpool/types/genesis.go index b16e4ff97e7c..632a36573469 100644 --- a/x/protocolpool/types/genesis.go +++ b/x/protocolpool/types/genesis.go @@ -1,9 +1,9 @@ package types import ( - "fmt" + "errors" - "cosmossdk.io/errors" + errorsmod "cosmossdk.io/errors" "cosmossdk.io/math" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" @@ -40,41 +40,41 @@ func ValidateGenesis(gs *GenesisState) error { func validateBudget(bp Budget) error { if bp.RecipientAddress == "" { - return fmt.Errorf("recipient cannot be empty") + return errors.New("recipient cannot be empty") } // Validate BudgetPerTranche if bp.BudgetPerTranche == nil || bp.BudgetPerTranche.IsZero() { - return fmt.Errorf("budget per tranche cannot be zero") + return errors.New("budget per tranche cannot be zero") } if err := bp.BudgetPerTranche.Validate(); err != nil { - return errors.Wrap(sdkerrors.ErrInvalidCoins, bp.BudgetPerTranche.String()) + return errorsmod.Wrap(sdkerrors.ErrInvalidCoins, bp.BudgetPerTranche.String()) } if bp.TranchesLeft == 0 { - return fmt.Errorf("invalid budget proposal: tranches must be greater than zero") + return errors.New("invalid budget proposal: tranches must be greater than zero") } if bp.Period == nil || *bp.Period == 0 { - return fmt.Errorf("invalid budget proposal: period length should be greater than zero") + return errors.New("invalid budget proposal: period length should be greater than zero") } return nil } func validateContinuousFund(cf ContinuousFund) error { if cf.Recipient == "" { - return fmt.Errorf("recipient cannot be empty") + return errors.New("recipient cannot be empty") } // Validate percentage if cf.Percentage.IsNil() || cf.Percentage.IsZero() { - return fmt.Errorf("percentage cannot be zero or empty") + return errors.New("percentage cannot be zero or empty") } if cf.Percentage.IsNegative() { - return fmt.Errorf("percentage cannot be negative") + return errors.New("percentage cannot be negative") } if cf.Percentage.GT(math.LegacyOneDec()) { - return fmt.Errorf("percentage cannot be greater than one") + return errors.New("percentage cannot be greater than one") } return nil } diff --git a/x/simulation/simulate.go b/x/simulation/simulate.go index 9335f032473c..15bbd353cc2c 100644 --- a/x/simulation/simulate.go +++ b/x/simulation/simulate.go @@ -4,6 +4,7 @@ import ( "bytes" "encoding/binary" "encoding/hex" + "errors" "fmt" "io" "math/rand" @@ -113,7 +114,7 @@ func SimulateFromSeedX( // At least 2 accounts must be added here, otherwise when executing SimulateMsgSend // two accounts will be selected to meet the conditions from != to and it will fall into an infinite loop. if len(accs) <= 1 { - return params, fmt.Errorf("at least two genesis accounts are required") + return params, errors.New("at least two genesis accounts are required") } config.ChainID = chainID diff --git a/x/staking/keeper/delegation.go b/x/staking/keeper/delegation.go index 1db3cc99a2fc..69ad3843ee9c 100644 --- a/x/staking/keeper/delegation.go +++ b/x/staking/keeper/delegation.go @@ -719,7 +719,7 @@ func (k Keeper) Delegate( // all non bonded if subtractAccount { if tokenSrc == types.Bonded { - return math.LegacyZeroDec(), fmt.Errorf("delegation token source cannot be bonded; expected Unbonded or Unbonding, got Bonded") + return math.LegacyZeroDec(), errors.New("delegation token source cannot be bonded; expected Unbonded or Unbonding, got Bonded") } var sendName string diff --git a/x/staking/keeper/slash.go b/x/staking/keeper/slash.go index 3e78cdb949ea..5179752a5b58 100644 --- a/x/staking/keeper/slash.go +++ b/x/staking/keeper/slash.go @@ -190,7 +190,7 @@ func (k Keeper) Slash(ctx context.Context, consAddr sdk.ConsAddress, infractionH return math.NewInt(0), err } default: - return math.NewInt(0), fmt.Errorf("invalid validator status") + return math.NewInt(0), errors.New("invalid validator status") } k.Logger.Info( @@ -415,7 +415,7 @@ func (k Keeper) SlashRedelegation(ctx context.Context, srcValidator types.Valida case dstValidator.IsUnbonded() || dstValidator.IsUnbonding(): notBondedBurnedAmount = notBondedBurnedAmount.Add(tokensToBurn) default: - return math.ZeroInt(), fmt.Errorf("unknown validator status") + return math.ZeroInt(), errors.New("unknown validator status") } } diff --git a/x/staking/keeper/val_state_change.go b/x/staking/keeper/val_state_change.go index ac6d82eb27ee..8d71114c1585 100644 --- a/x/staking/keeper/val_state_change.go +++ b/x/staking/keeper/val_state_change.go @@ -3,6 +3,7 @@ package keeper import ( "bytes" "context" + "errors" "fmt" "sort" @@ -172,7 +173,7 @@ func (k Keeper) ApplyAndReturnValidatorSetUpdates(ctx context.Context) ([]appmod } if validator.Jailed { - return nil, fmt.Errorf("should never retrieve a jailed validator from the power store") + return nil, errors.New("should never retrieve a jailed validator from the power store") } // if we get to a zero-power validator (which we don't bond), @@ -198,7 +199,7 @@ func (k Keeper) ApplyAndReturnValidatorSetUpdates(ctx context.Context) ([]appmod case validator.IsBonded(): // no state change default: - return nil, fmt.Errorf("unexpected validator status") + return nil, errors.New("unexpected validator status") } // fetch the old power bytes diff --git a/x/staking/keeper/validator.go b/x/staking/keeper/validator.go index 908cff4d8ed9..7ce5cae9822a 100644 --- a/x/staking/keeper/validator.go +++ b/x/staking/keeper/validator.go @@ -542,7 +542,7 @@ func (k Keeper) unbondMatureValidators( } if !val.IsUnbonding() { - return fmt.Errorf("unexpected validator in unbonding queue; status was not unbonding") + return errors.New("unexpected validator in unbonding queue; status was not unbonding") } // if the ref count is not zero, early exit. diff --git a/x/staking/types/params.go b/x/staking/types/params.go index 5e27278cda90..bd619ae2c0b2 100644 --- a/x/staking/types/params.go +++ b/x/staking/types/params.go @@ -188,7 +188,7 @@ func ValidatePowerReduction(i interface{}) error { } if v.LT(math.NewInt(1)) { - return fmt.Errorf("power reduction cannot be lower than 1") + return errors.New("power reduction cannot be lower than 1") } return nil diff --git a/x/upgrade/keeper/keeper.go b/x/upgrade/keeper/keeper.go index 237ee21fb202..bafd410e9405 100644 --- a/x/upgrade/keeper/keeper.go +++ b/x/upgrade/keeper/keeper.go @@ -415,7 +415,7 @@ func (k Keeper) HasHandler(name string) bool { func (k Keeper) ApplyUpgrade(ctx context.Context, plan types.Plan) error { handler := k.upgradeHandlers[plan.Name] if handler == nil { - return fmt.Errorf("ApplyUpgrade should never be called without first checking HasHandler") + return errors.New("ApplyUpgrade should never be called without first checking HasHandler") } vm, err := k.GetModuleVersionMap(ctx) diff --git a/x/upgrade/keeper/migrations.go b/x/upgrade/keeper/migrations.go index 2cee9df2fe67..bd257236d873 100644 --- a/x/upgrade/keeper/migrations.go +++ b/x/upgrade/keeper/migrations.go @@ -3,6 +3,7 @@ package keeper import ( "context" "encoding/binary" + "errors" "fmt" storetypes "cosmossdk.io/core/store" @@ -63,7 +64,7 @@ func (m Migrator) Migrate2to3(ctx context.Context) error { func migrateAppVersion(ctx context.Context, keeper *Keeper) error { if keeper.versionModifier == nil { - return fmt.Errorf("version modifier is not set") + return errors.New("version modifier is not set") } store := keeper.KVStoreService.OpenKVStore(ctx) From 6f1592d3da374efb47fa06dc7a74f380e24cb4ee Mon Sep 17 00:00:00 2001 From: son trinh Date: Sun, 21 Jul 2024 19:24:56 +0700 Subject: [PATCH 13/50] fix: NewIntegrationApp does not write default genesis to state (#21006) --- CHANGELOG.md | 1 + testutil/integration/router.go | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3641552f84a2..be30e89daadc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -117,6 +117,7 @@ Every module contains its own CHANGELOG.md. Please refer to the module you are i * [#19851](https://github.com/cosmos/cosmos-sdk/pull/19851) Fix some places in which we call Remove inside a Walk (x/staking and x/gov). * [#20939](https://github.com/cosmos/cosmos-sdk/pull/20939) Fix collection reverse iterator to include `pagination.key` in the result. * (client/grpc) [#20969](https://github.com/cosmos/cosmos-sdk/pull/20969) Fix `node.NewQueryServer` method not setting `cfg`. +* (testutil/integration) [#21006](https://github.com/cosmos/cosmos-sdk/pull/21006) Fix `NewIntegrationApp` method not writing default genesis to state ### API Breaking Changes diff --git a/testutil/integration/router.go b/testutil/integration/router.go index 0e4724779425..952d371df191 100644 --- a/testutil/integration/router.go +++ b/testutil/integration/router.go @@ -64,10 +64,10 @@ func NewIntegrationApp( bApp := baseapp.NewBaseApp(appName, logger, db, txConfig.TxDecoder(), baseapp.SetChainID(appName)) bApp.MountKVStores(keys) - bApp.SetInitChainer(func(ctx sdk.Context, _ *cmtabcitypes.InitChainRequest) (*cmtabcitypes.InitChainResponse, error) { + bApp.SetInitChainer(func(_ sdk.Context, _ *cmtabcitypes.InitChainRequest) (*cmtabcitypes.InitChainResponse, error) { for _, mod := range modules { if m, ok := mod.(module.HasGenesis); ok { - if err := m.InitGenesis(ctx, m.DefaultGenesis()); err != nil { + if err := m.InitGenesis(sdkCtx, m.DefaultGenesis()); err != nil { return nil, err } } From d2dc3eed299ec8df94d22026e289ba79020f6d9e Mon Sep 17 00:00:00 2001 From: Halimao <1065621723@qq.com> Date: Mon, 22 Jul 2024 01:54:22 +0800 Subject: [PATCH 14/50] fix: make help won't work (#21005) --- scripts/build/localnet.mk | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/build/localnet.mk b/scripts/build/localnet.mk index 2bc94a7351d8..931e8b421285 100644 --- a/scripts/build/localnet.mk +++ b/scripts/build/localnet.mk @@ -27,7 +27,7 @@ localnet-debug: localnet-stop localnet-build-dlv localnet-build-nodes .PHONY: localnet-start localnet-stop localnet-debug localnet-build-env localnet-build-dlv localnet-build-nodes #? help: Get more info on make commands. -help: Makefile +help: @echo " Choose a command run in "$(PROJECT_NAME)":" - @sed -n 's/^#?//p' $< | column -t -s ':' | sort | sed -e 's/^/ /' + @cat $(MAKEFILE_LIST) | sed -n 's/^#?//p' | column -t -s ':' | sort | sed -e 's/^/ /' .PHONY: help From f9f2ad7fa96b3cb2a52ecd3d6d5e8b927ee62009 Mon Sep 17 00:00:00 2001 From: Akhil Kumar P <36399231+akhilkumarpilli@users.noreply.github.com> Date: Mon, 22 Jul 2024 12:38:08 +0530 Subject: [PATCH 15/50] fix(simapp/v2): panic with testnet init-files command (#21012) --- simapp/v2/simdv2/cmd/root_test.go | 2 +- simapp/v2/simdv2/cmd/testnet.go | 2 +- simapp/v2/simdv2/cmd/testnet_test.go | 27 +++++++++++++++++++++++++++ 3 files changed, 29 insertions(+), 2 deletions(-) create mode 100644 simapp/v2/simdv2/cmd/testnet_test.go diff --git a/simapp/v2/simdv2/cmd/root_test.go b/simapp/v2/simdv2/cmd/root_test.go index a945a9ee8c85..7c51b1b21170 100644 --- a/simapp/v2/simdv2/cmd/root_test.go +++ b/simapp/v2/simdv2/cmd/root_test.go @@ -7,11 +7,11 @@ import ( "github.com/stretchr/testify/require" "cosmossdk.io/core/transaction" + svrcmd "cosmossdk.io/server/v2" "cosmossdk.io/simapp/v2" "cosmossdk.io/simapp/v2/simdv2/cmd" "github.com/cosmos/cosmos-sdk/client/flags" - svrcmd "github.com/cosmos/cosmos-sdk/server/cmd" "github.com/cosmos/cosmos-sdk/x/genutil/client/cli" ) diff --git a/simapp/v2/simdv2/cmd/testnet.go b/simapp/v2/simdv2/cmd/testnet.go index d1a15cfcbc93..024926de70b9 100644 --- a/simapp/v2/simdv2/cmd/testnet.go +++ b/simapp/v2/simdv2/cmd/testnet.go @@ -198,7 +198,7 @@ func initTestnetFiles[T transaction.Tx]( // generate private keys, node IDs, and initial transactions for i := 0; i < args.numValidators; i++ { var portOffset int - var grpcConfig *grpc.Config + grpcConfig := grpc.DefaultConfig() if args.singleMachine { portOffset = i p2pPortStart = 16656 // use different start point to not conflict with rpc port diff --git a/simapp/v2/simdv2/cmd/testnet_test.go b/simapp/v2/simdv2/cmd/testnet_test.go new file mode 100644 index 000000000000..145a32608e60 --- /dev/null +++ b/simapp/v2/simdv2/cmd/testnet_test.go @@ -0,0 +1,27 @@ +package cmd_test + +import ( + "fmt" + "testing" + + "github.com/stretchr/testify/require" + + "cosmossdk.io/core/transaction" + svrcmd "cosmossdk.io/server/v2" + "cosmossdk.io/simapp/v2" + "cosmossdk.io/simapp/v2/simdv2/cmd" + + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/cosmos/cosmos-sdk/crypto/keyring" +) + +func TestInitTestFilesCmd(t *testing.T) { + rootCmd := cmd.NewRootCmd[transaction.Tx]() + rootCmd.SetArgs([]string{ + "testnet", // Test the testnet init-files command + "init-files", + fmt.Sprintf("--%s=%s", flags.FlagKeyringBackend, keyring.BackendTest), // Set keyring-backend to test + }) + + require.NoError(t, svrcmd.Execute(rootCmd, "", simapp.DefaultNodeHome)) +} From 331eaf42f36a1a035037f20128b531e057696559 Mon Sep 17 00:00:00 2001 From: winniehere Date: Mon, 22 Jul 2024 15:35:43 +0800 Subject: [PATCH 16/50] chore(docs): fix functions and struct comments (#21010) --- api/cosmos/base/node/v1beta1/query.pulsar.go | 2 +- client/grpc/node/query.pb.go | 2 +- proto/cosmos/base/node/v1beta1/query.proto | 2 +- tests/integration/example/example_test.go | 2 +- x/auth/ante/sigverify.go | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/api/cosmos/base/node/v1beta1/query.pulsar.go b/api/cosmos/base/node/v1beta1/query.pulsar.go index dcec17ddc233..ae4e61914747 100644 --- a/api/cosmos/base/node/v1beta1/query.pulsar.go +++ b/api/cosmos/base/node/v1beta1/query.pulsar.go @@ -2113,7 +2113,7 @@ func (*StatusRequest) Descriptor() ([]byte, []int) { return file_cosmos_base_node_v1beta1_query_proto_rawDescGZIP(), []int{2} } -// StateResponse defines the response structure for the status of a node. +// StatusResponse defines the response structure for the status of a node. type StatusResponse struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache diff --git a/client/grpc/node/query.pb.go b/client/grpc/node/query.pb.go index e35556035670..4fa49a40070e 100644 --- a/client/grpc/node/query.pb.go +++ b/client/grpc/node/query.pb.go @@ -176,7 +176,7 @@ func (m *StatusRequest) XXX_DiscardUnknown() { var xxx_messageInfo_StatusRequest proto.InternalMessageInfo -// StateResponse defines the response structure for the status of a node. +// StatusResponse defines the response structure for the status of a node. type StatusResponse struct { EarliestStoreHeight uint64 `protobuf:"varint,1,opt,name=earliest_store_height,json=earliestStoreHeight,proto3" json:"earliest_store_height,omitempty"` Height uint64 `protobuf:"varint,2,opt,name=height,proto3" json:"height,omitempty"` diff --git a/proto/cosmos/base/node/v1beta1/query.proto b/proto/cosmos/base/node/v1beta1/query.proto index 999eddc9c03d..268c85b79d5e 100644 --- a/proto/cosmos/base/node/v1beta1/query.proto +++ b/proto/cosmos/base/node/v1beta1/query.proto @@ -33,7 +33,7 @@ message ConfigResponse { // StatusRequest defines the request structure for the status of a node. message StatusRequest {} -// StateResponse defines the response structure for the status of a node. +// StatusResponse defines the response structure for the status of a node. message StatusResponse { uint64 earliest_store_height = 1; // earliest block height available in the store uint64 height = 2; // current block height diff --git a/tests/integration/example/example_test.go b/tests/integration/example/example_test.go index 92fdbbeebb07..56f49dab8ed4 100644 --- a/tests/integration/example/example_test.go +++ b/tests/integration/example/example_test.go @@ -137,7 +137,7 @@ func Example() { // Output: 10000 } -// ExampleOneModule shows how to use the integration test framework to test the integration of a single module. +// Example_oneModule shows how to use the integration test framework to test the integration of a single module. // That module has no dependency on other modules. func Example_oneModule() { // in this example we are testing the integration of the auth module: diff --git a/x/auth/ante/sigverify.go b/x/auth/ante/sigverify.go index 1856f2c311f6..a435ba03bdfa 100644 --- a/x/auth/ante/sigverify.go +++ b/x/auth/ante/sigverify.go @@ -464,7 +464,7 @@ func NewValidateSigCountDecorator(ak AccountKeeper) ValidateSigCountDecorator { } } -// AnteHandler implements an ante decorator for ValidateSigCountDecorator +// AnteHandle implements an ante decorator for ValidateSigCountDecorator func (vscd ValidateSigCountDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, _ bool, next sdk.AnteHandler) (newCtx sdk.Context, err error) { if err := vscd.ValidateTx(ctx, tx); err != nil { return ctx, err From ae4af887d0d08bdea4b323669ed7b85f59288398 Mon Sep 17 00:00:00 2001 From: Halimao <1065621723@qq.com> Date: Mon, 22 Jul 2024 17:02:41 +0800 Subject: [PATCH 17/50] fix(simapp): duplicated import (#21014) --- simapp/app.go | 42 ++++++++++++++++++++---------------------- 1 file changed, 20 insertions(+), 22 deletions(-) diff --git a/simapp/app.go b/simapp/app.go index 64232666e565..96366c85abcc 100644 --- a/simapp/app.go +++ b/simapp/app.go @@ -52,7 +52,6 @@ import ( "cosmossdk.io/x/consensus" consensusparamkeeper "cosmossdk.io/x/consensus/keeper" consensusparamtypes "cosmossdk.io/x/consensus/types" - consensustypes "cosmossdk.io/x/consensus/types" distr "cosmossdk.io/x/distribution" distrkeeper "cosmossdk.io/x/distribution/keeper" distrtypes "cosmossdk.io/x/distribution/types" @@ -81,7 +80,6 @@ import ( "cosmossdk.io/x/protocolpool" poolkeeper "cosmossdk.io/x/protocolpool/keeper" pooltypes "cosmossdk.io/x/protocolpool/types" - protocolpooltypes "cosmossdk.io/x/protocolpool/types" "cosmossdk.io/x/slashing" slashingkeeper "cosmossdk.io/x/slashing/keeper" slashingtypes "cosmossdk.io/x/slashing/types" @@ -440,26 +438,26 @@ func NewSimApp( // NOTE: Any module instantiated in the module manager that is later modified // must be passed by reference here. app.ModuleManager = module.NewManagerFromMap(map[string]appmodule.AppModule{ - genutiltypes.ModuleName: genutil.NewAppModule(appCodec, app.AuthKeeper, app.StakingKeeper, app, txConfig, genutiltypes.DefaultMessageValidator), - accounts.ModuleName: accounts.NewAppModule(appCodec, app.AccountsKeeper), - authtypes.ModuleName: auth.NewAppModule(appCodec, app.AuthKeeper, app.AccountsKeeper, authsims.RandomGenesisAccounts), - vestingtypes.ModuleName: vesting.NewAppModule(app.AuthKeeper, app.BankKeeper), - banktypes.ModuleName: bank.NewAppModule(appCodec, app.BankKeeper, app.AuthKeeper), - feegrant.ModuleName: feegrantmodule.NewAppModule(appCodec, app.AuthKeeper, app.BankKeeper, app.FeeGrantKeeper, app.interfaceRegistry), - govtypes.ModuleName: gov.NewAppModule(appCodec, &app.GovKeeper, app.AuthKeeper, app.BankKeeper, app.PoolKeeper), - minttypes.ModuleName: mint.NewAppModule(appCodec, app.MintKeeper, app.AuthKeeper, nil), - slashingtypes.ModuleName: slashing.NewAppModule(appCodec, app.SlashingKeeper, app.AuthKeeper, app.BankKeeper, app.StakingKeeper, app.interfaceRegistry, cometService), - distrtypes.ModuleName: distr.NewAppModule(appCodec, app.DistrKeeper, app.AuthKeeper, app.BankKeeper, app.StakingKeeper, app.PoolKeeper), - stakingtypes.ModuleName: staking.NewAppModule(appCodec, app.StakingKeeper, app.AuthKeeper, app.BankKeeper), - upgradetypes.ModuleName: upgrade.NewAppModule(app.UpgradeKeeper), - evidencetypes.ModuleName: evidence.NewAppModule(appCodec, app.EvidenceKeeper, cometService), - authz.ModuleName: authzmodule.NewAppModule(appCodec, app.AuthzKeeper, app.AuthKeeper, app.BankKeeper, app.interfaceRegistry), - group.ModuleName: groupmodule.NewAppModule(appCodec, app.GroupKeeper, app.AuthKeeper, app.BankKeeper, app.interfaceRegistry), - nft.ModuleName: nftmodule.NewAppModule(appCodec, app.NFTKeeper, app.AuthKeeper, app.BankKeeper, app.interfaceRegistry), - consensustypes.ModuleName: consensus.NewAppModule(appCodec, app.ConsensusParamsKeeper), - circuittypes.ModuleName: circuit.NewAppModule(appCodec, app.CircuitKeeper), - protocolpooltypes.ModuleName: protocolpool.NewAppModule(appCodec, app.PoolKeeper, app.AuthKeeper, app.BankKeeper), - epochstypes.ModuleName: epochs.NewAppModule(appCodec, app.EpochsKeeper), + genutiltypes.ModuleName: genutil.NewAppModule(appCodec, app.AuthKeeper, app.StakingKeeper, app, txConfig, genutiltypes.DefaultMessageValidator), + accounts.ModuleName: accounts.NewAppModule(appCodec, app.AccountsKeeper), + authtypes.ModuleName: auth.NewAppModule(appCodec, app.AuthKeeper, app.AccountsKeeper, authsims.RandomGenesisAccounts), + vestingtypes.ModuleName: vesting.NewAppModule(app.AuthKeeper, app.BankKeeper), + banktypes.ModuleName: bank.NewAppModule(appCodec, app.BankKeeper, app.AuthKeeper), + feegrant.ModuleName: feegrantmodule.NewAppModule(appCodec, app.AuthKeeper, app.BankKeeper, app.FeeGrantKeeper, app.interfaceRegistry), + govtypes.ModuleName: gov.NewAppModule(appCodec, &app.GovKeeper, app.AuthKeeper, app.BankKeeper, app.PoolKeeper), + minttypes.ModuleName: mint.NewAppModule(appCodec, app.MintKeeper, app.AuthKeeper, nil), + slashingtypes.ModuleName: slashing.NewAppModule(appCodec, app.SlashingKeeper, app.AuthKeeper, app.BankKeeper, app.StakingKeeper, app.interfaceRegistry, cometService), + distrtypes.ModuleName: distr.NewAppModule(appCodec, app.DistrKeeper, app.AuthKeeper, app.BankKeeper, app.StakingKeeper, app.PoolKeeper), + stakingtypes.ModuleName: staking.NewAppModule(appCodec, app.StakingKeeper, app.AuthKeeper, app.BankKeeper), + upgradetypes.ModuleName: upgrade.NewAppModule(app.UpgradeKeeper), + evidencetypes.ModuleName: evidence.NewAppModule(appCodec, app.EvidenceKeeper, cometService), + authz.ModuleName: authzmodule.NewAppModule(appCodec, app.AuthzKeeper, app.AuthKeeper, app.BankKeeper, app.interfaceRegistry), + group.ModuleName: groupmodule.NewAppModule(appCodec, app.GroupKeeper, app.AuthKeeper, app.BankKeeper, app.interfaceRegistry), + nft.ModuleName: nftmodule.NewAppModule(appCodec, app.NFTKeeper, app.AuthKeeper, app.BankKeeper, app.interfaceRegistry), + consensusparamtypes.ModuleName: consensus.NewAppModule(appCodec, app.ConsensusParamsKeeper), + circuittypes.ModuleName: circuit.NewAppModule(appCodec, app.CircuitKeeper), + pooltypes.ModuleName: protocolpool.NewAppModule(appCodec, app.PoolKeeper, app.AuthKeeper, app.BankKeeper), + epochstypes.ModuleName: epochs.NewAppModule(appCodec, app.EpochsKeeper), }) app.ModuleManager.RegisterLegacyAminoCodec(legacyAmino) From 4b3a0b0afe341b089bcb35a99c4eba544ec376f9 Mon Sep 17 00:00:00 2001 From: Halimao <1065621723@qq.com> Date: Mon, 22 Jul 2024 17:28:20 +0800 Subject: [PATCH 18/50] refactor: set `help` as default target of Makefile (#21011) --- Makefile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Makefile b/Makefile index bf814eb5f5c7..2e760653bfc9 100644 --- a/Makefile +++ b/Makefile @@ -8,6 +8,8 @@ include scripts/build/testing.mk include scripts/build/documentation.mk include scripts/build/build.mk +.DEFAULT_GOAL := help + ############################################################################### ### Tools & Dependencies ### ############################################################################### From 8484dc50e22dec6190ff45f8711a9f339bcdb437 Mon Sep 17 00:00:00 2001 From: Julien Robert Date: Mon, 22 Jul 2024 11:36:35 +0200 Subject: [PATCH 19/50] feat(server/v2/cometbft): config (#20989) --- runtime/v2/app.go | 5 + runtime/v2/builder.go | 1 - server/v2/api/grpc/server.go | 2 +- server/v2/api/grpcgateway/server.go | 2 +- server/v2/cometbft/abci.go | 92 ++++++++++--------- server/v2/cometbft/commands.go | 27 +++--- server/v2/cometbft/config.go | 86 +++++++++-------- server/v2/cometbft/flags.go | 35 ++++--- server/v2/cometbft/go.mod | 2 +- server/v2/cometbft/options.go | 6 ++ server/v2/cometbft/query.go | 17 ++-- server/v2/cometbft/server.go | 138 ++++++++++++++++++---------- server/v2/cometbft/utils.go | 14 +-- server/v2/cometbft/version.go | 26 ++++++ server/v2/commands.go | 19 ++-- server/v2/config.go | 70 +++++++++++--- server/v2/config_test.go | 39 ++++++++ server/v2/go.mod | 2 +- server/v2/server.go | 51 +++++----- server/v2/server_test.go | 71 +++----------- server/v2/testdata/app.toml | 2 +- server/v2/types.go | 3 +- simapp/v2/simdv2/cmd/commands.go | 86 ++++++++--------- simapp/v2/simdv2/cmd/testnet.go | 11 ++- 24 files changed, 468 insertions(+), 339 deletions(-) create mode 100644 server/v2/cometbft/version.go create mode 100644 server/v2/config_test.go diff --git a/runtime/v2/app.go b/runtime/v2/app.go index 014849c497b0..89d6d0be24ba 100644 --- a/runtime/v2/app.go +++ b/runtime/v2/app.go @@ -51,6 +51,11 @@ type App[T transaction.Tx] struct { GRPCQueryDecoders map[string]func(requestBytes []byte) (gogoproto.Message, error) } +// Name returns the app name. +func (a *App[T]) Name() string { + return a.config.AppName +} + // Logger returns the app logger. func (a *App[T]) Logger() log.Logger { return a.logger diff --git a/runtime/v2/builder.go b/runtime/v2/builder.go index 2618b0f0be5d..82e418349d56 100644 --- a/runtime/v2/builder.go +++ b/runtime/v2/builder.go @@ -117,7 +117,6 @@ func (a *AppBuilder[T]) Build(opts ...AppBuilderOption[T]) (*App[T], error) { if err != nil { return nil, fmt.Errorf("failed to create STF: %w", err) } - a.app.stf = stf rs, err := rootstore.CreateRootStore(a.storeOptions) diff --git a/server/v2/api/grpc/server.go b/server/v2/api/grpc/server.go index 7f73472a330f..c5e31f5dfc71 100644 --- a/server/v2/api/grpc/server.go +++ b/server/v2/api/grpc/server.go @@ -34,7 +34,7 @@ func New[T transaction.Tx](cfgOptions ...CfgOption) *GRPCServer[T] { func (s *GRPCServer[T]) Init(appI serverv2.AppI[T], v *viper.Viper, logger log.Logger) error { cfg := s.Config().(*Config) if v != nil { - if err := v.Sub(s.Name()).Unmarshal(&cfg); err != nil { + if err := serverv2.UnmarshalSubConfig(v, s.Name(), &cfg); err != nil { return fmt.Errorf("failed to unmarshal config: %w", err) } } diff --git a/server/v2/api/grpcgateway/server.go b/server/v2/api/grpcgateway/server.go index 7a5693f8c5be..a8a67590df20 100644 --- a/server/v2/api/grpcgateway/server.go +++ b/server/v2/api/grpcgateway/server.go @@ -84,7 +84,7 @@ func (s *GRPCGatewayServer[T]) Config() any { func (s *GRPCGatewayServer[T]) Init(appI serverv2.AppI[transaction.Tx], v *viper.Viper, logger log.Logger) error { cfg := s.Config().(*Config) if v != nil { - if err := v.Sub(s.Name()).Unmarshal(&cfg); err != nil { + if err := serverv2.UnmarshalSubConfig(v, s.Name(), &cfg); err != nil { return fmt.Errorf("failed to unmarshal config: %w", err) } } diff --git a/server/v2/cometbft/abci.go b/server/v2/cometbft/abci.go index f63953b0c8d3..ad69cf9a941d 100644 --- a/server/v2/cometbft/abci.go +++ b/server/v2/cometbft/abci.go @@ -32,18 +32,22 @@ import ( var _ abci.Application = (*Consensus[transaction.Tx])(nil) type Consensus[T transaction.Tx] struct { - // legacy support for gRPC - grpcQueryDecoders map[string]func(requestBytes []byte) (gogoproto.Message, error) - - app *appmanager.AppManager[T] - cfg Config - store types.Store - logger log.Logger - txCodec transaction.Codec[T] - streaming streaming.Manager - snapshotManager *snapshots.Manager - mempool mempool.Mempool[T] - + logger log.Logger + appName, version string + consensusAuthority string // Set by the application to grant authority to the consensus engine to send messages to the consensus module + app *appmanager.AppManager[T] + txCodec transaction.Codec[T] + store types.Store + streaming streaming.Manager + snapshotManager *snapshots.Manager + mempool mempool.Mempool[T] + grpcQueryDecoders map[string]func(requestBytes []byte) (gogoproto.Message, error) // legacy support for gRPC + + cfg Config + indexedEvents map[string]struct{} + chainID string + + initialHeight uint64 // this is only available after this node has committed a block (in FinalizeBlock), // otherwise it will be empty and we will need to query the app for the last // committed block. @@ -54,19 +58,26 @@ type Consensus[T transaction.Tx] struct { verifyVoteExt handlers.VerifyVoteExtensionhandler extendVote handlers.ExtendVoteHandler - chainID string + addrPeerFilter types.PeerFilter // filter peers by address and port + idPeerFilter types.PeerFilter // filter peers by node ID } func NewConsensus[T transaction.Tx]( + logger log.Logger, + appName string, + consensusAuthority string, app *appmanager.AppManager[T], mp mempool.Mempool[T], + indexedEvents map[string]struct{}, grpcQueryDecoders map[string]func(requestBytes []byte) (gogoproto.Message, error), store types.Store, cfg Config, txCodec transaction.Codec[T], - logger log.Logger, ) *Consensus[T] { return &Consensus[T]{ + appName: appName, + version: getCometBFTServerVersion(), + consensusAuthority: consensusAuthority, grpcQueryDecoders: grpcQueryDecoders, app: app, cfg: cfg, @@ -82,27 +93,24 @@ func NewConsensus[T transaction.Tx]( verifyVoteExt: nil, extendVote: nil, chainID: "", + indexedEvents: indexedEvents, + initialHeight: 0, } } +// SetStreamingManager sets the streaming manager for the consensus module. func (c *Consensus[T]) SetStreamingManager(sm streaming.Manager) { c.streaming = sm } -// SetSnapshotManager sets the snapshot manager for the Consensus. -// The snapshot manager is responsible for managing snapshots of the Consensus state. -// It allows for creating, storing, and restoring snapshots of the Consensus state. -// The provided snapshot manager will be used by the Consensus to handle snapshots. -func (c *Consensus[T]) SetSnapshotManager(sm *snapshots.Manager) { - c.snapshotManager = sm -} - // RegisterExtensions registers the given extensions with the consensus module's snapshot manager. // It allows additional snapshotter implementations to be used for creating and restoring snapshots. -func (c *Consensus[T]) RegisterExtensions(extensions ...snapshots.ExtensionSnapshotter) { +func (c *Consensus[T]) RegisterSnapshotExtensions(extensions ...snapshots.ExtensionSnapshotter) error { if err := c.snapshotManager.RegisterExtensions(extensions...); err != nil { - panic(fmt.Errorf("failed to register snapshot extensions: %w", err)) + return fmt.Errorf("failed to register snapshot extensions: %w", err) } + + return nil } // CheckTx implements types.Application. @@ -122,7 +130,7 @@ func (c *Consensus[T]) CheckTx(ctx context.Context, req *abciproto.CheckTxReques Code: resp.Code, GasWanted: uint64ToInt64(resp.GasWanted), GasUsed: uint64ToInt64(resp.GasUsed), - Events: intoABCIEvents(resp.Events, c.cfg.IndexEvents), + Events: intoABCIEvents(resp.Events, c.indexedEvents), Info: resp.Info, Data: resp.Data, Log: resp.Log, @@ -144,7 +152,7 @@ func (c *Consensus[T]) Info(ctx context.Context, _ *abciproto.InfoRequest) (*abc // cp, err := c.GetConsensusParams(ctx) // if err != nil { - // return nil, err + // return nil, err // } cid, err := c.store.LastCommitID() @@ -153,10 +161,9 @@ func (c *Consensus[T]) Info(ctx context.Context, _ *abciproto.InfoRequest) (*abc } return &abciproto.InfoResponse{ - Data: c.cfg.Name, - Version: c.cfg.Version, - // AppVersion: cp.GetVersion().App, - AppVersion: 0, // TODO fetch from store? + Data: c.appName, + Version: c.version, + AppVersion: 0, // TODO fetch consensus params? LastBlockHeight: int64(version), LastBlockAppHash: cid.Hash, }, nil @@ -173,7 +180,6 @@ func (c *Consensus[T]) Query(ctx context.Context, req *abciproto.QueryRequest) ( return nil, fmt.Errorf("unable to decode gRPC request with path %s from ABCI.Query: %w", req.Path, err) } res, err := c.app.Query(ctx, uint64(req.Height), protoRequest) - if err != nil { resp := queryResult(err) resp.Height = req.Height @@ -188,7 +194,7 @@ func (c *Consensus[T]) Query(ctx context.Context, req *abciproto.QueryRequest) ( // it must be an app/p2p/store query path := splitABCIQueryPath(req.Path) if len(path) == 0 { - return QueryResult(errorsmod.Wrap(cometerrors.ErrUnknownRequest, "no query path provided"), c.cfg.Trace), nil + return QueryResult(errorsmod.Wrap(cometerrors.ErrUnknownRequest, "no query path provided"), c.cfg.AppTomlConfig.Trace), nil } switch path[0] { @@ -202,11 +208,11 @@ func (c *Consensus[T]) Query(ctx context.Context, req *abciproto.QueryRequest) ( resp, err = c.handleQueryP2P(path) default: - resp = QueryResult(errorsmod.Wrap(cometerrors.ErrUnknownRequest, "unknown query path"), c.cfg.Trace) + resp = QueryResult(errorsmod.Wrap(cometerrors.ErrUnknownRequest, "unknown query path"), c.cfg.AppTomlConfig.Trace) } if err != nil { - return QueryResult(err, c.cfg.Trace), nil + return QueryResult(err, c.cfg.AppTomlConfig.Trace), nil } return resp, nil @@ -218,17 +224,17 @@ func (c *Consensus[T]) InitChain(ctx context.Context, req *abciproto.InitChainRe // store chainID to be used later on in execution c.chainID = req.ChainId - // TODO: check if we need to load the config from genesis.json or config.toml - c.cfg.InitialHeight = uint64(req.InitialHeight) - // On a new chain, we consider the init chain block height as 0, even though - // req.InitialHeight is 1 by default. - // TODO + // TODO: check if we need to load the config from genesis.json or config.toml + c.initialHeight = uint64(req.InitialHeight) + if c.initialHeight == 0 { // If initial height is 0, set it to 1 + c.initialHeight = 1 + } var consMessages []transaction.Msg if req.ConsensusParams != nil { consMessages = append(consMessages, &consensustypes.MsgUpdateParams{ - Authority: c.cfg.ConsensusAuthority, + Authority: c.consensusAuthority, Block: req.ConsensusParams.Block, Evidence: req.ConsensusParams.Evidence, Validator: req.ConsensusParams.Validator, @@ -394,7 +400,7 @@ func (c *Consensus[T]) FinalizeBlock( // TODO evaluate this approach vs. service using context. // cometInfo := &consensustypes.MsgUpdateCometInfo{ - // Authority: c.cfg.ConsensusAuthority, + // Authority: c.consensusAuthority, // CometInfo: &consensustypes.CometInfo{ // Evidence: req.Misbehavior, // ValidatorsHash: req.NextValidatorsHash, @@ -411,7 +417,7 @@ func (c *Consensus[T]) FinalizeBlock( // }) // we don't need to deliver the block in the genesis block - if req.Height == int64(c.cfg.InitialHeight) { + if req.Height == int64(c.initialHeight) { appHash, err := c.store.Commit(store.NewChangeset()) if err != nil { return nil, fmt.Errorf("unable to commit the changeset: %w", err) @@ -495,7 +501,7 @@ func (c *Consensus[T]) FinalizeBlock( return nil, err } - return finalizeBlockResponse(resp, cp, appHash, c.cfg.IndexEvents) + return finalizeBlockResponse(resp, cp, appHash, c.indexedEvents) } // Commit implements types.Application. diff --git a/server/v2/cometbft/commands.go b/server/v2/cometbft/commands.go index 7c72cfe56ecc..16c1e30905eb 100644 --- a/server/v2/cometbft/commands.go +++ b/server/v2/cometbft/commands.go @@ -19,7 +19,6 @@ import ( "sigs.k8s.io/yaml" "cosmossdk.io/server/v2/cometbft/client/rpc" - auth "cosmossdk.io/x/auth/client/cli" "github.com/cosmos/cosmos-sdk/client" cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" @@ -29,7 +28,7 @@ import ( ) func (s *CometBFTServer[T]) rpcClient(cmd *cobra.Command) (rpc.CometRPC, error) { - if s.config.Standalone { + if s.config.AppTomlConfig.Standalone { client, err := rpchttp.New(client.GetConfigFromCmd(cmd).RPC.ListenAddress) if err != nil { return nil, err @@ -201,10 +200,10 @@ for. Each module documents its respective events under 'xx_events.md'. return err } - query, _ := cmd.Flags().GetString(auth.FlagQuery) + query, _ := cmd.Flags().GetString(FlagQuery) page, _ := cmd.Flags().GetInt(FlagPage) limit, _ := cmd.Flags().GetInt(FlagLimit) - orderBy, _ := cmd.Flags().GetString(auth.FlagOrderBy) + orderBy, _ := cmd.Flags().GetString(FlagOrderBy) blocks, err := rpc.QueryBlocks(cmd.Context(), rpcclient, page, limit, query, orderBy) if err != nil { @@ -223,9 +222,9 @@ for. Each module documents its respective events under 'xx_events.md'. AddQueryFlagsToCmd(cmd) cmd.Flags().Int(FlagPage, query.DefaultPage, "Query a specific page of paginated results") cmd.Flags().Int(FlagLimit, query.DefaultLimit, "Query number of transactions results per page returned") - cmd.Flags().String(auth.FlagQuery, "", "The blocks events query per CometBFT's query semantics") - cmd.Flags().String(auth.FlagOrderBy, "", "The ordering semantics (asc|dsc)") - _ = cmd.MarkFlagRequired(auth.FlagQuery) + cmd.Flags().String(FlagQuery, "", "The blocks events query per CometBFT's query semantics") + cmd.Flags().String(FlagOrderBy, "", "The ordering semantics (asc|dsc)") + _ = cmd.MarkFlagRequired(FlagQuery) return cmd } @@ -240,11 +239,11 @@ func (s *CometBFTServer[T]) QueryBlockCmd() *cobra.Command { $ %s query block --%s=%s $ %s query block --%s=%s `, - version.AppName, auth.FlagType, auth.TypeHeight, - version.AppName, auth.FlagType, auth.TypeHash)), + version.AppName, FlagType, TypeHeight, + version.AppName, FlagType, TypeHash)), Args: cobra.ExactArgs(1), RunE: func(cmd *cobra.Command, args []string) error { - typ, _ := cmd.Flags().GetString(auth.FlagType) + typ, _ := cmd.Flags().GetString(FlagType) rpcclient, err := s.rpcClient(cmd) if err != nil { @@ -252,7 +251,7 @@ $ %s query block --%s=%s } switch typ { - case auth.TypeHeight: + case TypeHeight: if args[0] == "" { return fmt.Errorf("argument should be a block height") } @@ -282,7 +281,7 @@ $ %s query block --%s=%s return printOutput(cmd, bz) - case auth.TypeHash: + case TypeHash: if args[0] == "" { return fmt.Errorf("argument should be a tx hash") @@ -306,13 +305,13 @@ $ %s query block --%s=%s return printOutput(cmd, bz) default: - return fmt.Errorf("unknown --%s value %s", auth.FlagType, typ) + return fmt.Errorf("unknown --%s value %s", FlagType, typ) } }, } AddQueryFlagsToCmd(cmd) - cmd.Flags().String(auth.FlagType, auth.TypeHash, fmt.Sprintf("The type to be used when querying tx, can be one of \"%s\", \"%s\"", auth.TypeHeight, auth.TypeHash)) + cmd.Flags().String(FlagType, TypeHash, fmt.Sprintf("The type to be used when querying tx, can be one of \"%s\", \"%s\"", TypeHeight, TypeHash)) return cmd } diff --git a/server/v2/cometbft/config.go b/server/v2/cometbft/config.go index e349cf6dc563..d04082972434 100644 --- a/server/v2/cometbft/config.go +++ b/server/v2/cometbft/config.go @@ -5,54 +5,62 @@ import ( "github.com/spf13/viper" serverv2 "cosmossdk.io/server/v2" - "cosmossdk.io/server/v2/cometbft/types" ) -// TODO REDO/VERIFY THIS +// Config is the configuration for the CometBFT application +type Config struct { + AppTomlConfig *AppTomlConfig + ConfigTomlConfig *cmtcfg.Config +} -func GetConfigFromViper(v *viper.Viper) *cmtcfg.Config { - conf := cmtcfg.DefaultConfig() - err := v.Unmarshal(conf) - rootDir := v.GetString(serverv2.FlagHome) - if err != nil { - return cmtcfg.DefaultConfig().SetRoot(rootDir) +func DefaultAppTomlConfig() *AppTomlConfig { + return &AppTomlConfig{ + MinRetainBlocks: 0, + IndexEvents: make([]string, 0), + HaltHeight: 0, + HaltTime: 0, + Address: "tcp://127.0.0.1:26658", + Transport: "socket", + Trace: false, + Standalone: false, } +} - return conf.SetRoot(rootDir) +type AppTomlConfig struct { + MinRetainBlocks uint64 `mapstructure:"min_retain_blocks" toml:"min_retain_blocks" comment:"min_retain_blocks defines the minimum block height offset from the current block being committed, such that all blocks past this offset are pruned from CometBFT. A value of 0 indicates that no blocks should be pruned."` + IndexEvents []string `mapstructure:"index_events" toml:"index_events" comment:"index_events defines the set of events in the form {eventType}.{attributeKey}, which informs CometBFT what to index. If empty, all events will be indexed."` + HaltHeight uint64 `mapstructure:"halt_height" toml:"halt_height" comment:"halt_height contains a non-zero block height at which a node will gracefully halt and shutdown that can be used to assist upgrades and testing."` + HaltTime uint64 `mapstructure:"halt_time" toml:"halt_time" comment:"halt_time contains a non-zero minimum block time (in Unix seconds) at which a node will gracefully halt and shutdown that can be used to assist upgrades and testing."` + Address string `mapstructure:"address" toml:"address" comment:"address defines the CometBFT RPC server address to bind to."` + Transport string `mapstructure:"transport" toml:"transport" comment:"transport defines the CometBFT RPC server transport protocol: socket, grpc"` + Trace bool `mapstructure:"trace" toml:"trace" comment:"trace enables the CometBFT RPC server to output trace information about its internal operations."` + Standalone bool `mapstructure:"standalone" toml:"standalone" comment:"standalone starts the application without the CometBFT node. The node should be started separately."` } -// Config is the configuration for the CometBFT application -type Config struct { - // app.toml config options - Name string `mapstructure:"name" toml:"name"` - Version string `mapstructure:"version" toml:"version"` - InitialHeight uint64 `mapstructure:"initial_height" toml:"initial_height"` - MinRetainBlocks uint64 `mapstructure:"min_retain_blocks" toml:"min_retain_blocks"` - IndexEvents map[string]struct{} `mapstructure:"index_events" toml:"index_events"` - HaltHeight uint64 `mapstructure:"halt_height" toml:"halt_height"` - HaltTime uint64 `mapstructure:"halt_time" toml:"halt_time"` - // end of app.toml config options - - AddrPeerFilter types.PeerFilter // filter peers by address and port - IdPeerFilter types.PeerFilter // filter peers by node ID - - Transport string `mapstructure:"transport" toml:"transport"` - Addr string `mapstructure:"addr" toml:"addr"` - Standalone bool `mapstructure:"standalone" toml:"standalone"` - Trace bool `mapstructure:"trace" toml:"trace"` - // Must be set by the application to grant authority to the consensus engine to send messages to the consensus module - ConsensusAuthority string - - // config.toml - CmtConfig *cmtcfg.Config +// CfgOption is a function that allows to overwrite the default server configuration. +type CfgOption func(*Config) + +// OverwriteDefaultConfigTomlConfig overwrites the default comet config with the new config. +func OverwriteDefaultConfigTomlConfig(newCfg *cmtcfg.Config) CfgOption { + return func(cfg *Config) { + cfg.ConfigTomlConfig = newCfg // nolint:ineffassign,staticcheck // We want to overwrite everything + } +} + +// OverwriteDefaultAppTomlConfig overwrites the default comet config with the new config. +func OverwriteDefaultAppTomlConfig(newCfg *AppTomlConfig) CfgOption { + return func(cfg *Config) { + cfg.AppTomlConfig = newCfg // nolint:ineffassign,staticcheck // We want to overwrite everything + } } -// CmtCfgOption is a function that allows to overwrite the default server configuration. -type CmtCfgOption func(*cmtcfg.Config) +func getConfigTomlFromViper(v *viper.Viper) *cmtcfg.Config { + rootDir := v.GetString(serverv2.FlagHome) -// OverwriteDefaultCometConfig overwrites the default comet config with the new config. -func OverwriteDefaultCometConfig(newCfg *cmtcfg.Config) CmtCfgOption { - return func(cfg *cmtcfg.Config) { // nolint:staticcheck // We want to overwrite everything - cfg = newCfg // nolint:ineffassign,staticcheck // We want to overwrite everything + conf := cmtcfg.DefaultConfig() + if err := v.Unmarshal(conf); err != nil { + return cmtcfg.DefaultConfig().SetRoot(rootDir) } + + return conf.SetRoot(rootDir) } diff --git a/server/v2/cometbft/flags.go b/server/v2/cometbft/flags.go index fe1442edf6c5..00d57b81fb78 100644 --- a/server/v2/cometbft/flags.go +++ b/server/v2/cometbft/flags.go @@ -2,26 +2,11 @@ package cometbft import "github.com/spf13/cobra" +// Query flags const ( - FlagQuery = "query" - FlagType = "type" - FlagOrderBy = "order_by" -) - -const ( - FlagWithComet = "with-comet" - FlagAddress = "address" - FlagTransport = "transport" - FlagTraceStore = "trace-store" - FlagCPUProfile = "cpu-profile" - FlagMinGasPrices = "minimum-gas-prices" - FlagQueryGasLimit = "query-gas-limit" - FlagHaltHeight = "halt-height" - FlagHaltTime = "halt-time" - FlagTrace = "trace" -) - -const ( + FlagQuery = "query" + FlagType = "type" + FlagOrderBy = "order_by" FlagChainID = "chain-id" FlagNode = "node" FlagGRPC = "grpc-addr" @@ -30,6 +15,8 @@ const ( FlagPage = "page" FlagLimit = "limit" FlagOutput = "output" + TypeHash = "hash" + TypeHeight = "height" ) // List of supported output formats @@ -50,3 +37,13 @@ func AddQueryFlagsToCmd(cmd *cobra.Command) { // hence the flag should not be required for those commands _ = cmd.MarkFlagRequired(FlagChainID) } + +// Server flags +const ( + Standalone = "standalone" + FlagAddress = "address" + FlagTransport = "transport" + FlagHaltHeight = "halt-height" + FlagHaltTime = "halt-time" + FlagTrace = "trace" +) diff --git a/server/v2/cometbft/go.mod b/server/v2/cometbft/go.mod index 78e8545dcd26..2d3aebb30984 100644 --- a/server/v2/cometbft/go.mod +++ b/server/v2/cometbft/go.mod @@ -29,7 +29,6 @@ require ( cosmossdk.io/server/v2 v2.0.0-00010101000000-000000000000 cosmossdk.io/server/v2/appmanager v0.0.0-00010101000000-000000000000 cosmossdk.io/store/v2 v2.0.0-00010101000000-000000000000 - cosmossdk.io/x/auth v0.0.0-00010101000000-000000000000 cosmossdk.io/x/consensus v0.0.0-00010101000000-000000000000 github.com/cometbft/cometbft v1.0.0-rc1 github.com/cometbft/cometbft/api v1.0.0-rc.1 @@ -56,6 +55,7 @@ require ( cosmossdk.io/math v1.3.0 // indirect cosmossdk.io/schema v0.1.1 // indirect cosmossdk.io/store v1.1.1-0.20240418092142-896cdf1971bc // indirect + cosmossdk.io/x/auth v0.0.0-00010101000000-000000000000 // indirect cosmossdk.io/x/bank v0.0.0-20240226161501-23359a0b6d91 // indirect cosmossdk.io/x/staking v0.0.0-00010101000000-000000000000 // indirect cosmossdk.io/x/tx v0.13.3 // indirect diff --git a/server/v2/cometbft/options.go b/server/v2/cometbft/options.go index 0950609f7da9..1e0a389882e0 100644 --- a/server/v2/cometbft/options.go +++ b/server/v2/cometbft/options.go @@ -4,6 +4,7 @@ import ( "cosmossdk.io/core/transaction" "cosmossdk.io/server/v2/cometbft/handlers" "cosmossdk.io/server/v2/cometbft/mempool" + "cosmossdk.io/server/v2/cometbft/types" "cosmossdk.io/store/v2/snapshots" ) @@ -16,6 +17,9 @@ type ServerOptions[T transaction.Tx] struct { ExtendVoteHandler handlers.ExtendVoteHandler SnapshotOptions snapshots.SnapshotOptions + + AddrPeerFilter types.PeerFilter // filter peers by address and port + IdPeerFilter types.PeerFilter // filter peers by node ID } // DefaultServerOptions returns the default server options. @@ -28,5 +32,7 @@ func DefaultServerOptions[T transaction.Tx]() ServerOptions[T] { VerifyVoteExtensionHandler: handlers.NoOpVerifyVoteExtensionHandler(), ExtendVoteHandler: handlers.NoOpExtendVote(), SnapshotOptions: snapshots.NewSnapshotOptions(0, 0), + AddrPeerFilter: nil, + IdPeerFilter: nil, } } diff --git a/server/v2/cometbft/query.go b/server/v2/cometbft/query.go index d45c97cd078b..912338ff79f3 100644 --- a/server/v2/cometbft/query.go +++ b/server/v2/cometbft/query.go @@ -20,13 +20,14 @@ func (c *Consensus[T]) handleQueryP2P(path []string) (*abci.QueryResponse, error cmd, typ, arg := path[1], path[2], path[3] if cmd == "filter" { - if typ == "addr" { - if c.cfg.AddrPeerFilter != nil { - return c.cfg.AddrPeerFilter(arg) + switch typ { + case "addr": + if c.addrPeerFilter != nil { + return c.addrPeerFilter(arg) } - } else if typ == "id" { - if c.cfg.IdPeerFilter != nil { - return c.cfg.IdPeerFilter(arg) + case "id": + if c.idPeerFilter != nil { + return c.idPeerFilter(arg) } } } @@ -61,7 +62,7 @@ func (c *Consensus[T]) handlerQueryApp(ctx context.Context, path []string, req * return nil, errorsmod.Wrap(err, "failed to simulate tx") } - bz, err := intoABCISimulationResponse(txResult, c.cfg.IndexEvents) + bz, err := intoABCISimulationResponse(txResult, c.indexedEvents) if err != nil { return nil, errorsmod.Wrap(err, "failed to marshal txResult") } @@ -75,7 +76,7 @@ func (c *Consensus[T]) handlerQueryApp(ctx context.Context, path []string, req * case "version": return &abci.QueryResponse{ Codespace: cometerrors.RootCodespace, - Value: []byte(c.cfg.Version), + Value: []byte(c.version), Height: req.Height, }, nil } diff --git a/server/v2/cometbft/server.go b/server/v2/cometbft/server.go index 9b84a776400c..1553a5c9a592 100644 --- a/server/v2/cometbft/server.go +++ b/server/v2/cometbft/server.go @@ -18,7 +18,6 @@ import ( "github.com/spf13/pflag" "github.com/spf13/viper" - corectx "cosmossdk.io/core/context" "cosmossdk.io/core/log" "cosmossdk.io/core/transaction" serverv2 "cosmossdk.io/server/v2" @@ -39,47 +38,71 @@ type CometBFTServer[T transaction.Tx] struct { Node *node.Node Consensus *Consensus[T] - initTxCodec transaction.Codec[T] - logger log.Logger - config Config - options ServerOptions[T] - cmtConfigOptions []CmtCfgOption + initTxCodec transaction.Codec[T] + logger log.Logger + serverOptions ServerOptions[T] + config Config + cfgOptions []CfgOption } -func New[T transaction.Tx](txCodec transaction.Codec[T], options ServerOptions[T], cfgOptions ...CmtCfgOption) *CometBFTServer[T] { +func New[T transaction.Tx](txCodec transaction.Codec[T], serverOptions ServerOptions[T], cfgOptions ...CfgOption) *CometBFTServer[T] { return &CometBFTServer[T]{ - initTxCodec: txCodec, - options: options, - cmtConfigOptions: cfgOptions, + initTxCodec: txCodec, + serverOptions: serverOptions, + cfgOptions: cfgOptions, } } func (s *CometBFTServer[T]) Init(appI serverv2.AppI[T], v *viper.Viper, logger log.Logger) error { - s.config = Config{CmtConfig: GetConfigFromViper(v), ConsensusAuthority: appI.GetConsensusAuthority()} - s.logger = logger.With(log.ModuleKey, s.Name()) + // get configs (app.toml + config.toml) from viper + appTomlConfig := s.Config().(*AppTomlConfig) + if v != nil { + if err := serverv2.UnmarshalSubConfig(v, s.Name(), &appTomlConfig); err != nil { + return fmt.Errorf("failed to unmarshal config: %w", err) + } + } + s.config = Config{ + ConfigTomlConfig: getConfigTomlFromViper(v), + AppTomlConfig: appTomlConfig, + } - // create consensus - store := appI.GetStore().(types.Store) - consensus := NewConsensus[T](appI.GetAppManager(), s.options.Mempool, appI.GetGRPCQueryDecoders(), store, s.config, s.initTxCodec, s.logger) + indexEvents := make(map[string]struct{}, len(s.config.AppTomlConfig.IndexEvents)) + for _, e := range s.config.AppTomlConfig.IndexEvents { + indexEvents[e] = struct{}{} + } - consensus.prepareProposalHandler = s.options.PrepareProposalHandler - consensus.processProposalHandler = s.options.ProcessProposalHandler - consensus.verifyVoteExt = s.options.VerifyVoteExtensionHandler - consensus.extendVote = s.options.ExtendVoteHandler + s.logger = logger.With(log.ModuleKey, s.Name()) + consensus := NewConsensus( + s.logger, + appI.Name(), + appI.GetConsensusAuthority(), + appI.GetAppManager(), + s.serverOptions.Mempool, + indexEvents, + appI.GetGRPCQueryDecoders(), + appI.GetStore().(types.Store), + s.config, + s.initTxCodec, + ) + consensus.prepareProposalHandler = s.serverOptions.PrepareProposalHandler + consensus.processProposalHandler = s.serverOptions.ProcessProposalHandler + consensus.verifyVoteExt = s.serverOptions.VerifyVoteExtensionHandler + consensus.extendVote = s.serverOptions.ExtendVoteHandler + consensus.addrPeerFilter = s.serverOptions.AddrPeerFilter + consensus.idPeerFilter = s.serverOptions.IdPeerFilter // TODO: set these; what is the appropriate presence of the Store interface here? var ss snapshots.StorageSnapshotter var sc snapshots.CommitSnapshotter - snapshotStore, err := GetSnapshotStore(s.config.CmtConfig.RootDir) + snapshotStore, err := GetSnapshotStore(s.config.ConfigTomlConfig.RootDir) if err != nil { return err } - - sm := snapshots.NewManager(snapshotStore, s.options.SnapshotOptions, sc, ss, nil, s.logger) - consensus.SetSnapshotManager(sm) + consensus.snapshotManager = snapshots.NewManager(snapshotStore, s.serverOptions.SnapshotOptions, sc, ss, nil, s.logger) s.Consensus = consensus + return nil } @@ -88,12 +111,9 @@ func (s *CometBFTServer[T]) Name() string { } func (s *CometBFTServer[T]) Start(ctx context.Context) error { - viper := ctx.Value(corectx.ViperContextKey).(*viper.Viper) - cometConfig := GetConfigFromViper(viper) - wrappedLogger := cometlog.CometLoggerWrapper{Logger: s.logger} - if s.config.Standalone { - svr, err := abciserver.NewServer(s.config.Addr, s.config.Transport, s.Consensus) + if s.config.AppTomlConfig.Standalone { + svr, err := abciserver.NewServer(s.config.AppTomlConfig.Address, s.config.AppTomlConfig.Transport, s.Consensus) if err != nil { return fmt.Errorf("error creating listener: %w", err) } @@ -103,20 +123,20 @@ func (s *CometBFTServer[T]) Start(ctx context.Context) error { return svr.Start() } - nodeKey, err := p2p.LoadOrGenNodeKey(cometConfig.NodeKeyFile()) + nodeKey, err := p2p.LoadOrGenNodeKey(s.config.ConfigTomlConfig.NodeKeyFile()) if err != nil { return err } s.Node, err = node.NewNode( ctx, - cometConfig, - pvm.LoadOrGenFilePV(cometConfig.PrivValidatorKeyFile(), cometConfig.PrivValidatorStateFile()), + s.config.ConfigTomlConfig, + pvm.LoadOrGenFilePV(s.config.ConfigTomlConfig.PrivValidatorKeyFile(), s.config.ConfigTomlConfig.PrivValidatorStateFile()), nodeKey, proxy.NewConsensusSyncLocalClientCreator(s.Consensus), - getGenDocProvider(cometConfig), + getGenDocProvider(s.config.ConfigTomlConfig), cmtcfg.DefaultDBProvider, - node.DefaultMetricsProvider(cometConfig.Instrumentation), + node.DefaultMetricsProvider(s.config.ConfigTomlConfig.Instrumentation), wrappedLogger, ) if err != nil { @@ -174,16 +194,20 @@ func getGenDocProvider(cfg *cmtcfg.Config) func() (node.ChecksummedGenesisDoc, e func (s *CometBFTServer[T]) StartCmdFlags() *pflag.FlagSet { flags := pflag.NewFlagSet("cometbft", pflag.ExitOnError) - flags.Bool(FlagWithComet, true, "Run abci app embedded in-process with CometBFT") - flags.String(FlagAddress, "tcp://127.0.0.1:26658", "Listen address") - flags.String(FlagTransport, "socket", "Transport protocol: socket, grpc") - flags.String(FlagTraceStore, "", "Enable KVStore tracing to an output file") - flags.String(FlagMinGasPrices, "", "Minimum gas prices to accept for transactions; Any fee in a tx must meet this minimum (e.g. 0.01photino;0.0001stake)") - flags.Uint64(FlagQueryGasLimit, 0, "Maximum gas a Rest/Grpc query can consume. Blank and 0 imply unbounded.") - flags.Uint64(FlagHaltHeight, 0, "Block height at which to gracefully halt the chain and shutdown the node") - flags.Uint64(FlagHaltTime, 0, "Minimum block time (in Unix seconds) at which to gracefully halt the chain and shutdown the node") - flags.String(FlagCPUProfile, "", "Enable CPU profiling and write to the provided file") - flags.Bool(FlagTrace, false, "Provide full stack traces for errors in ABCI Log") + + // start flags are prefixed with the server name + // as the config in prefixed with the server name + // this allows viper to properly bind the flags + prefix := func(f string) string { + return fmt.Sprintf("%s.%s", s.Name(), f) + } + + flags.String(prefix(FlagAddress), "tcp://127.0.0.1:26658", "Listen address") + flags.String(prefix(FlagTransport), "socket", "Transport protocol: socket, grpc") + flags.Uint64(prefix(FlagHaltHeight), 0, "Block height at which to gracefully halt the chain and shutdown the node") + flags.Uint64(prefix(FlagHaltTime), 0, "Minimum block time (in Unix seconds) at which to gracefully halt the chain and shutdown the node") + flags.Bool(prefix(FlagTrace), false, "Provide full stack traces for errors in ABCI Log") + flags.Bool(prefix(Standalone), false, "Run app without CometBFT") return flags } @@ -206,12 +230,30 @@ func (s *CometBFTServer[T]) CLICommands() serverv2.CLIConfig { } } -func (s *CometBFTServer[T]) WriteDefaultConfigAt(configPath string) error { - cometConfig := cmtcfg.DefaultConfig() - for _, opt := range s.cmtConfigOptions { - opt(cometConfig) +// CometBFT is a special server, it has config in config.toml and app.toml + +// Config returns the (app.toml) server configuration. +func (s *CometBFTServer[T]) Config() any { + if s.config.AppTomlConfig == nil || s.config.AppTomlConfig == (&AppTomlConfig{}) { + cfg := &Config{AppTomlConfig: DefaultAppTomlConfig()} + // overwrite the default config with the provided options + for _, opt := range s.cfgOptions { + opt(cfg) + } + + return cfg.AppTomlConfig + } + + return s.config.AppTomlConfig +} + +// WriteCustomConfigAt writes the default cometbft config.toml +func (s *CometBFTServer[T]) WriteCustomConfigAt(configPath string) error { + cfg := &Config{ConfigTomlConfig: cmtcfg.DefaultConfig()} + for _, opt := range s.cfgOptions { + opt(cfg) } - cmtcfg.WriteConfigFile(filepath.Join(configPath, "config.toml"), cometConfig) + cmtcfg.WriteConfigFile(filepath.Join(configPath, "config.toml"), cfg.ConfigTomlConfig) return nil } diff --git a/server/v2/cometbft/utils.go b/server/v2/cometbft/utils.go index b302e90c78c3..b4bfb5a6dd30 100644 --- a/server/v2/cometbft/utils.go +++ b/server/v2/cometbft/utils.go @@ -262,10 +262,10 @@ func (c *Consensus[T]) validateFinalizeBlockHeight(req *abci.FinalizeBlockReques // expectedHeight holds the expected height to validate var expectedHeight uint64 - if lastBlockHeight == 0 && c.cfg.InitialHeight > 1 { + if lastBlockHeight == 0 && c.initialHeight > 1 { // In this case, we're validating the first block of the chain, i.e no // previous commit. The height we're expecting is the initial height. - expectedHeight = c.cfg.InitialHeight + expectedHeight = c.initialHeight } else { // This case can mean two things: // @@ -327,7 +327,7 @@ func (c *Consensus[T]) GetConsensusParams(ctx context.Context) (*cmtproto.Consen func (c *Consensus[T]) GetBlockRetentionHeight(cp *cmtproto.ConsensusParams, commitHeight int64) int64 { // pruning is disabled if minRetainBlocks is zero - if c.cfg.MinRetainBlocks == 0 { + if c.cfg.AppTomlConfig.MinRetainBlocks == 0 { return 0 } @@ -368,7 +368,7 @@ func (c *Consensus[T]) GetBlockRetentionHeight(cp *cmtproto.ConsensusParams, com } } - v := commitHeight - int64(c.cfg.MinRetainBlocks) + v := commitHeight - int64(c.cfg.AppTomlConfig.MinRetainBlocks) retentionHeight = minNonZero(retentionHeight, v) if retentionHeight <= 0 { @@ -383,15 +383,15 @@ func (c *Consensus[T]) GetBlockRetentionHeight(cp *cmtproto.ConsensusParams, com func (c *Consensus[T]) checkHalt(height int64, time time.Time) error { var halt bool switch { - case c.cfg.HaltHeight > 0 && uint64(height) > c.cfg.HaltHeight: + case c.cfg.AppTomlConfig.HaltHeight > 0 && uint64(height) > c.cfg.AppTomlConfig.HaltHeight: halt = true - case c.cfg.HaltTime > 0 && time.Unix() > int64(c.cfg.HaltTime): + case c.cfg.AppTomlConfig.HaltTime > 0 && time.Unix() > int64(c.cfg.AppTomlConfig.HaltTime): halt = true } if halt { - return fmt.Errorf("halt per configuration height %d time %d", c.cfg.HaltHeight, c.cfg.HaltTime) + return fmt.Errorf("halt per configuration height %d time %d", c.cfg.AppTomlConfig.HaltHeight, c.cfg.AppTomlConfig.HaltTime) } return nil diff --git a/server/v2/cometbft/version.go b/server/v2/cometbft/version.go new file mode 100644 index 000000000000..1151f819ac39 --- /dev/null +++ b/server/v2/cometbft/version.go @@ -0,0 +1,26 @@ +package cometbft + +import "runtime/debug" + +var Version = "" + +func getCometBFTServerVersion() string { + deps, ok := debug.ReadBuildInfo() + if !ok { + return Version + } + + var serverVersion string + for _, dep := range deps.Deps { + if dep.Path == "cosmossdk.io/server/v2/cometbft" { + if dep.Replace != nil && dep.Replace.Version != "(devel)" { + serverVersion = dep.Replace.Version + } else { + serverVersion = dep.Version + } + } + } + + Version = serverVersion + return serverVersion +} diff --git a/server/v2/commands.go b/server/v2/commands.go index dd62c1518ac6..a0b2b05ae902 100644 --- a/server/v2/commands.go +++ b/server/v2/commands.go @@ -3,7 +3,6 @@ package serverv2 import ( "context" "errors" - "fmt" "os" "os/signal" "path/filepath" @@ -102,19 +101,12 @@ func createStartCommand[T transaction.Tx]( ) *cobra.Command { flags := server.StartFlags() - return &cobra.Command{ + cmd := &cobra.Command{ Use: "start", Short: "Run the application", RunE: func(cmd *cobra.Command, args []string) error { v := GetViperFromCmd(cmd) l := GetLoggerFromCmd(cmd) - - for _, startFlags := range flags { - if err := v.BindPFlags(startFlags); err != nil { - return err - } - } - if err := v.BindPFlags(cmd.Flags()); err != nil { return err } @@ -137,12 +129,19 @@ func createStartCommand[T transaction.Tx]( }() if err := server.Start(ctx); err != nil { - return fmt.Errorf("failed to start servers: %w", err) + return err } return nil }, } + + // add the start flags to the command + for _, startFlags := range flags { + cmd.Flags().AddFlagSet(startFlags) + } + + return cmd } // configHandle writes the default config to the home directory if it does not exist and sets the server context diff --git a/server/v2/config.go b/server/v2/config.go index cb5fbeae7cb5..5a5936718929 100644 --- a/server/v2/config.go +++ b/server/v2/config.go @@ -1,15 +1,61 @@ package serverv2 -import "github.com/spf13/cobra" - -// CLIConfig defines the CLI configuration for a module server. -type CLIConfig struct { - // Commands defines the main command of a module server. - Commands []*cobra.Command - // Queries defines the query commands of a module server. - // Those commands are meant to be added in the root query command. - Queries []*cobra.Command - // Txs defines the tx commands of a module server. - // Those commands are meant to be added in the root tx command. - Txs []*cobra.Command +import ( + "fmt" + "strings" + + "github.com/mitchellh/mapstructure" + "github.com/spf13/viper" +) + +// ReadConfig returns a viper instance of the config file +func ReadConfig(configPath string) (*viper.Viper, error) { + v := viper.New() + v.SetConfigType("toml") + v.SetConfigName("config") + v.AddConfigPath(configPath) + if err := v.ReadInConfig(); err != nil { + return nil, fmt.Errorf("failed to read config: %s: %w", configPath, err) + } + + v.SetConfigName("app") + if err := v.MergeInConfig(); err != nil { + return nil, fmt.Errorf("failed to merge configuration: %w", err) + } + + v.WatchConfig() + + return v, nil +} + +// UnmarshalSubconfig unmarshals the given subconfig from the viper instance. +// It unmarshals the config, env, flags into the target struct. +// Use this instead of viper.Sub because viper does not unmarshal flags. +func UnmarshalSubConfig(v *viper.Viper, subName string, target any) error { + var sub any + for k, val := range v.AllSettings() { + if strings.HasPrefix(k, subName) { + sub = val + } + } + + // Create a new decoder with custom decoding options + decoder, err := mapstructure.NewDecoder(&mapstructure.DecoderConfig{ + DecodeHook: mapstructure.ComposeDecodeHookFunc( + mapstructure.StringToTimeDurationHookFunc(), + mapstructure.StringToSliceHookFunc(","), + ), + Result: target, + WeaklyTypedInput: true, + }) + if err != nil { + return fmt.Errorf("failed to create decoder: %w", err) + } + + // Decode the sub-configuration + if err := decoder.Decode(sub); err != nil { + return fmt.Errorf("failed to decode sub-configuration: %w", err) + } + + return nil } diff --git a/server/v2/config_test.go b/server/v2/config_test.go new file mode 100644 index 000000000000..24eb28bb7522 --- /dev/null +++ b/server/v2/config_test.go @@ -0,0 +1,39 @@ +package serverv2_test + +import ( + "os" + "path/filepath" + "testing" + + "github.com/stretchr/testify/require" + + serverv2 "cosmossdk.io/server/v2" + grpc "cosmossdk.io/server/v2/api/grpc" +) + +func TestReadConfig(t *testing.T) { + currentDir, err := os.Getwd() + require.NoError(t, err) + configPath := filepath.Join(currentDir, "testdata") + + v, err := serverv2.ReadConfig(configPath) + require.NoError(t, err) + + require.Equal(t, v.GetString("grpc.address"), grpc.DefaultConfig().Address) +} + +func TestUnmarshalSubConfig(t *testing.T) { + currentDir, err := os.Getwd() + require.NoError(t, err) + configPath := filepath.Join(currentDir, "testdata") + + v, err := serverv2.ReadConfig(configPath) + require.NoError(t, err) + + grpcConfig := grpc.DefaultConfig() + err = serverv2.UnmarshalSubConfig(v, "grpc", &grpcConfig) + require.NoError(t, err) + + require.True(t, grpc.DefaultConfig().Enable) + require.False(t, grpcConfig.Enable) +} diff --git a/server/v2/go.mod b/server/v2/go.mod index c82827815f93..4ff5ab253eea 100644 --- a/server/v2/go.mod +++ b/server/v2/go.mod @@ -28,6 +28,7 @@ require ( github.com/hashicorp/go-hclog v1.6.2 github.com/hashicorp/go-metrics v0.5.3 github.com/hashicorp/go-plugin v1.6.0 + github.com/mitchellh/mapstructure v1.5.0 github.com/pelletier/go-toml/v2 v2.2.2 github.com/prometheus/client_golang v1.19.1 github.com/prometheus/common v0.55.0 @@ -62,7 +63,6 @@ require ( github.com/mattn/go-colorable v0.1.13 // indirect github.com/mattn/go-isatty v0.0.20 // indirect github.com/mitchellh/go-testing-interface v1.14.1 // indirect - github.com/mitchellh/mapstructure v1.5.0 // indirect github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect github.com/oklog/run v1.1.0 // indirect github.com/pkg/errors v0.9.1 // indirect diff --git a/server/v2/server.go b/server/v2/server.go index 7dd4438097ca..6e1a4e7114db 100644 --- a/server/v2/server.go +++ b/server/v2/server.go @@ -26,9 +26,12 @@ type ServerComponent[T transaction.Tx] interface { Init(AppI[T], *viper.Viper, log.Logger) error } -// HasCLICommands is a server module that has CLI commands. -type HasCLICommands interface { - CLICommands() CLIConfig +// HasStartFlags is a server module that has start flags. +type HasStartFlags interface { + // StartCmdFlags returns server start flags. + // Those flags should be prefixed with the server name. + // They are then merged with the server config in one viper instance. + StartCmdFlags() *pflag.FlagSet } // HasConfig is a server module that has a config. @@ -36,33 +39,25 @@ type HasConfig interface { Config() any } -// HasStartFlags is a server module that has start flags. -type HasStartFlags interface { - StartCmdFlags() *pflag.FlagSet +// HasCLICommands is a server module that has CLI commands. +type HasCLICommands interface { + CLICommands() CLIConfig } -var _ ServerComponent[transaction.Tx] = (*Server[transaction.Tx])(nil) - -// ReadConfig returns a viper instance of the config file -func ReadConfig(configPath string) (*viper.Viper, error) { - v := viper.New() - v.SetConfigType("toml") - v.SetConfigName("config") - v.AddConfigPath(configPath) - if err := v.ReadInConfig(); err != nil { - return nil, fmt.Errorf("failed to read config: %s: %w", configPath, err) - } - - v.SetConfigName("app") - if err := v.MergeInConfig(); err != nil { - return nil, fmt.Errorf("failed to merge configuration: %w", err) - } - - v.WatchConfig() - - return v, nil +// CLIConfig defines the CLI configuration for a module server. +type CLIConfig struct { + // Commands defines the main command of a module server. + Commands []*cobra.Command + // Queries defines the query commands of a module server. + // Those commands are meant to be added in the root query command. + Queries []*cobra.Command + // Txs defines the tx commands of a module server. + // Those commands are meant to be added in the root tx command. + Txs []*cobra.Command } +var _ ServerComponent[transaction.Tx] = (*Server[transaction.Tx])(nil) + type Server[T transaction.Tx] struct { logger log.Logger components []ServerComponent[T] @@ -209,8 +204,8 @@ func (s *Server[T]) WriteConfig(configPath string) error { // undocumented interface to write the component default config in another file than app.toml // it is used by cometbft for backward compatibility // it should not be used by other components - if mod, ok := component.(interface{ WriteDefaultConfigAt(string) error }); ok { - if err := mod.WriteDefaultConfigAt(configPath); err != nil { + if mod, ok := component.(interface{ WriteCustomConfigAt(string) error }); ok { + if err := mod.WriteCustomConfigAt(configPath); err != nil { return err } } diff --git a/server/v2/server_test.go b/server/v2/server_test.go index 76102942006e..3faef417757b 100644 --- a/server/v2/server_test.go +++ b/server/v2/server_test.go @@ -37,19 +37,9 @@ func (*mockApp[T]) InterfaceRegistry() coreapp.InterfaceRegistry { return &mockInterfaceRegistry{} } -// TODO split this test into multiple tests -// test read config -// test write config -// test server configs -// test start empty -// test start config exists -// test stop func TestServer(t *testing.T) { currentDir, err := os.Getwd() - if err != nil { - t.Log(err) - t.Fail() - } + require.NoError(t, err) configPath := filepath.Join(currentDir, "testdata") v, err := serverv2.ReadConfig(configPath) @@ -59,10 +49,8 @@ func TestServer(t *testing.T) { logger := log.NewLogger(os.Stdout) grpcServer := grpc.New[transaction.Tx]() - if err := grpcServer.Init(&mockApp[transaction.Tx]{}, v, logger); err != nil { - t.Log(err) - t.Fail() - } + err = grpcServer.Init(&mockApp[transaction.Tx]{}, v, logger) + require.NoError(t, err) mockServer := &mockServer{name: "mock-server-1", ch: make(chan string, 100)} @@ -73,30 +61,17 @@ func TestServer(t *testing.T) { ) serverCfgs := server.Configs() - if serverCfgs[grpcServer.Name()].(*grpc.Config).Address != grpc.DefaultConfig().Address { - t.Logf("config is not equal: %v", serverCfgs[grpcServer.Name()]) - t.Fail() - } - if serverCfgs[mockServer.Name()].(*mockServerConfig).MockFieldOne != MockServerDefaultConfig().MockFieldOne { - t.Logf("config is not equal: %v", serverCfgs[mockServer.Name()]) - t.Fail() - } + require.Equal(t, serverCfgs[grpcServer.Name()].(*grpc.Config).Address, grpc.DefaultConfig().Address) + require.Equal(t, serverCfgs[mockServer.Name()].(*mockServerConfig).MockFieldOne, MockServerDefaultConfig().MockFieldOne) // write config - if err := server.WriteConfig(configPath); err != nil { - t.Log(err) - t.Fail() - } + err = server.WriteConfig(configPath) + require.NoError(t, err) v, err = serverv2.ReadConfig(configPath) - if err != nil { - t.Log(err) // config should be created by WriteConfig - t.FailNow() - } - if v.GetString(grpcServer.Name()+".address") != grpc.DefaultConfig().Address { - t.Logf("config is not equal: %v", v) - t.Fail() - } + require.NoError(t, err) + + require.Equal(t, v.GetString(grpcServer.Name()+".address"), grpc.DefaultConfig().Address) // start empty ctx, cancelFn := context.WithCancel(context.TODO()) @@ -105,30 +80,10 @@ func TestServer(t *testing.T) { <-time.After(5 * time.Second) cancelFn() - if err := server.Stop(ctx); err != nil { - t.Logf("failed to stop servers: %s", err) - t.Fail() - } + err = server.Stop(ctx) + require.NoError(t, err) }() - if err := server.Start(ctx); err != nil { - t.Log(err) - t.Fail() - } -} - -func TestReadConfig(t *testing.T) { - currentDir, err := os.Getwd() - if err != nil { - t.Log(err) - t.Fail() - } - configPath := filepath.Join(currentDir, "testdata") - - v, err := serverv2.ReadConfig(configPath) - require.NoError(t, err) - - grpcConfig := grpc.DefaultConfig() - err = v.Sub("grpc").Unmarshal(&grpcConfig) + err = server.Start(ctx) require.NoError(t, err) } diff --git a/server/v2/testdata/app.toml b/server/v2/testdata/app.toml index 34fb5b0b0239..20482ac44282 100644 --- a/server/v2/testdata/app.toml +++ b/server/v2/testdata/app.toml @@ -1,6 +1,6 @@ [grpc] # Enable defines if the gRPC server should be enabled. -enable = true +enable = false # Address defines the gRPC server address to bind to. address = 'localhost:9090' # MaxRecvMsgSize defines the max message size in bytes the server can receive. diff --git a/server/v2/types.go b/server/v2/types.go index 3382d1b27b6b..fc6caaaeb735 100644 --- a/server/v2/types.go +++ b/server/v2/types.go @@ -13,9 +13,10 @@ import ( type AppCreator[T transaction.Tx] func(log.Logger, *viper.Viper) AppI[T] type AppI[T transaction.Tx] interface { + Name() string + InterfaceRegistry() coreapp.InterfaceRegistry GetAppManager() *appmanager.AppManager[T] GetConsensusAuthority() string - InterfaceRegistry() coreapp.InterfaceRegistry GetGRPCQueryDecoders() map[string]func(requestBytes []byte) (gogoproto.Message, error) GetStore() any } diff --git a/simapp/v2/simdv2/cmd/commands.go b/simapp/v2/simdv2/cmd/commands.go index 0a677a80fa2e..fd32461c56ce 100644 --- a/simapp/v2/simdv2/cmd/commands.go +++ b/simapp/v2/simdv2/cmd/commands.go @@ -32,46 +32,6 @@ import ( genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types" ) -var _ transaction.Codec[transaction.Tx] = &temporaryTxDecoder[transaction.Tx]{} - -type temporaryTxDecoder[T transaction.Tx] struct { - txConfig client.TxConfig -} - -// Decode implements transaction.Codec. -func (t *temporaryTxDecoder[T]) Decode(bz []byte) (T, error) { - var out T - tx, err := t.txConfig.TxDecoder()(bz) - if err != nil { - return out, err - } - - var ok bool - out, ok = tx.(T) - if !ok { - return out, errors.New("unexpected Tx type") - } - - return out, nil -} - -// DecodeJSON implements transaction.Codec. -func (t *temporaryTxDecoder[T]) DecodeJSON(bz []byte) (T, error) { - var out T - tx, err := t.txConfig.TxJSONDecoder()(bz) - if err != nil { - return out, err - } - - var ok bool - out, ok = tx.(T) - if !ok { - return out, errors.New("unexpected Tx type") - } - - return out, nil -} - func newApp[T transaction.Tx]( logger log.Logger, viper *viper.Viper, ) serverv2.AppI[T] { @@ -102,19 +62,19 @@ func initRootCmd[T transaction.Tx]( // add keybase, auxiliary RPC, query, genesis, and tx child commands rootCmd.AddCommand( - genesisCommand[T](moduleManager, appExport[T]), + genesisCommand(moduleManager, appExport[T]), queryCommand(), txCommand(), keys.Commands(), offchain.OffChain(), ) - // Add empty server struct here for writing default config + // wire server commands if err = serverv2.AddCommands( rootCmd, newApp, logger, - cometbft.New[T](&temporaryTxDecoder[T]{txConfig}, cometbft.DefaultServerOptions[T]()), + cometbft.New(&genericTxDecoder[T]{txConfig}, cometbft.DefaultServerOptions[T]()), grpc.New[T](), ); err != nil { panic(err) @@ -220,3 +180,43 @@ func appExport[T transaction.Tx]( return simApp.ExportAppStateAndValidators(forZeroHeight, jailAllowedAddrs, modulesToExport) } + +var _ transaction.Codec[transaction.Tx] = &genericTxDecoder[transaction.Tx]{} + +type genericTxDecoder[T transaction.Tx] struct { + txConfig client.TxConfig +} + +// Decode implements transaction.Codec. +func (t *genericTxDecoder[T]) Decode(bz []byte) (T, error) { + var out T + tx, err := t.txConfig.TxDecoder()(bz) + if err != nil { + return out, err + } + + var ok bool + out, ok = tx.(T) + if !ok { + return out, errors.New("unexpected Tx type") + } + + return out, nil +} + +// DecodeJSON implements transaction.Codec. +func (t *genericTxDecoder[T]) DecodeJSON(bz []byte) (T, error) { + var out T + tx, err := t.txConfig.TxJSONDecoder()(bz) + if err != nil { + return out, err + } + + var ok bool + out, ok = tx.(T) + if !ok { + return out, errors.New("unexpected Tx type") + } + + return out, nil +} diff --git a/simapp/v2/simdv2/cmd/testnet.go b/simapp/v2/simdv2/cmd/testnet.go index 024926de70b9..b0a755a97190 100644 --- a/simapp/v2/simdv2/cmd/testnet.go +++ b/simapp/v2/simdv2/cmd/testnet.go @@ -40,6 +40,7 @@ import ( ) var ( + flagMinGasPrices = "min-gas-prices" flagNodeDirPrefix = "node-dir-prefix" flagNumValidators = "validator-count" flagOutputDir = "output-dir" @@ -70,7 +71,7 @@ func addTestnetFlagsToCmd(cmd *cobra.Command) { cmd.Flags().IntP(flagNumValidators, "n", 4, "Number of validators to initialize the testnet with") cmd.Flags().StringP(flagOutputDir, "o", "./.testnets", "Directory to store initialization data for the testnet") cmd.Flags().String(flags.FlagChainID, "", "genesis file chain-id, if left blank will be randomly created") - cmd.Flags().String(cometbft.FlagMinGasPrices, fmt.Sprintf("0.000006%s", sdk.DefaultBondDenom), "Minimum gas prices to accept for transactions; All fees in a tx must meet this minimum (e.g. 0.01photino,0.001stake)") + cmd.Flags().String(flagMinGasPrices, fmt.Sprintf("0.000006%s", sdk.DefaultBondDenom), "Minimum gas prices to accept for transactions; All fees in a tx must meet this minimum (e.g. 0.01photino,0.001stake)") cmd.Flags().String(flags.FlagKeyType, string(hd.Secp256k1Type), "Key signing algorithm to generate keys for") // support old flags name for backwards compatibility @@ -127,7 +128,7 @@ Example: args.outputDir, _ = cmd.Flags().GetString(flagOutputDir) args.keyringBackend, _ = cmd.Flags().GetString(flags.FlagKeyringBackend) args.chainID, _ = cmd.Flags().GetString(flags.FlagChainID) - args.minGasPrices, _ = cmd.Flags().GetString(cometbft.FlagMinGasPrices) + args.minGasPrices, _ = cmd.Flags().GetString(flagMinGasPrices) args.nodeDirPrefix, _ = cmd.Flags().GetString(flagNodeDirPrefix) args.nodeDaemonHome, _ = cmd.Flags().GetString(flagNodeDaemonHome) args.startingIPAddress, _ = cmd.Flags().GetString(flagStartingIPAddress) @@ -336,7 +337,11 @@ func initTestnetFiles[T transaction.Tx]( } // Write server config - cometServer := cometbft.New[T](&temporaryTxDecoder[T]{clientCtx.TxConfig}, cometbft.ServerOptions[T]{}, cometbft.OverwriteDefaultCometConfig(nodeConfig)) + cometServer := cometbft.New[T]( + &genericTxDecoder[T]{clientCtx.TxConfig}, + cometbft.ServerOptions[T]{}, + cometbft.OverwriteDefaultConfigTomlConfig(nodeConfig), + ) grpcServer := grpc.New[T](grpc.OverwriteDefaultConfig(grpcConfig)) server := serverv2.NewServer(coretesting.NewNopLogger(), cometServer, grpcServer) err = server.WriteConfig(filepath.Join(nodeDir, "config")) From 2d6f97e984a68e949e6527b03d169c83943b7ac2 Mon Sep 17 00:00:00 2001 From: son trinh Date: Mon, 22 Jul 2024 16:49:47 +0700 Subject: [PATCH 20/50] refactor(storev2): update snapshot manager and migration manager tests (#20441) --- store/v2/migration/manager_test.go | 5 + store/v2/root/store_test.go | 2 +- store/v2/snapshots/manager_test.go | 165 +++++++++++++++++++++++++++++ 3 files changed, 171 insertions(+), 1 deletion(-) diff --git a/store/v2/migration/manager_test.go b/store/v2/migration/manager_test.go index d57c4a67c22a..d8365ce07579 100644 --- a/store/v2/migration/manager_test.go +++ b/store/v2/migration/manager_test.go @@ -79,6 +79,11 @@ func TestMigrateState(t *testing.T) { err := m.Migrate(toVersion - 1) require.NoError(t, err) + // expecting error for conflicting process, since Migrate trigger snapshotter create migration, + // which start a snapshot process already. + _, err = m.snapshotsManager.Create(toVersion - 1) + require.Error(t, err) + if m.stateCommitment != nil { // check the migrated state for version := uint64(1); version < toVersion; version++ { diff --git a/store/v2/root/store_test.go b/store/v2/root/store_test.go index dd22fcaf4131..b2b640feb974 100644 --- a/store/v2/root/store_test.go +++ b/store/v2/root/store_test.go @@ -630,7 +630,7 @@ func (s *RootStoreTestSuite) TestMultiStore_PruningRestart() { return false } // wait for async pruning process to finish - s.Require().Eventually(checkErr, 2*time.Second, 100*time.Millisecond, "expected error when loading height: %d", v) + s.Require().Eventually(checkErr, 5*time.Second, 100*time.Millisecond, "expected error when loading height: %d", v) } } diff --git a/store/v2/snapshots/manager_test.go b/store/v2/snapshots/manager_test.go index f7ec801d7be2..2be8d4078758 100644 --- a/store/v2/snapshots/manager_test.go +++ b/store/v2/snapshots/manager_test.go @@ -8,6 +8,7 @@ import ( "github.com/stretchr/testify/require" coretesting "cosmossdk.io/core/testing" + "cosmossdk.io/log" "cosmossdk.io/store/v2/snapshots" "cosmossdk.io/store/v2/snapshots/types" ) @@ -254,3 +255,167 @@ func TestManager_TakeError(t *testing.T) { _, err = manager.Create(1) require.Error(t, err) } + +func TestSnapshot_Take_Restore(t *testing.T) { + store := setupStore(t) + items := [][]byte{ + {1, 2, 3}, + {4, 5, 6}, + {7, 8, 9}, + } + commitSnapshotter := &mockCommitSnapshotter{ + items: items, + } + extSnapshotter := newExtSnapshotter(10) + + expectChunks := snapshotItems(items, extSnapshotter) + manager := snapshots.NewManager(store, opts, commitSnapshotter, &mockStorageSnapshotter{}, nil, coretesting.NewNopLogger()) + err := manager.RegisterExtensions(extSnapshotter) + require.NoError(t, err) + + // creating a snapshot at a higher height should be fine, and should return it + snapshot, err := manager.Create(5) + require.NoError(t, err) + + assert.Equal(t, &types.Snapshot{ + Height: 5, + Format: commitSnapshotter.SnapshotFormat(), + Chunks: 1, + Hash: []uint8{0xc5, 0xf7, 0xfe, 0xea, 0xd3, 0x4d, 0x3e, 0x87, 0xff, 0x41, 0xa2, 0x27, 0xfa, 0xcb, 0x38, 0x17, 0xa, 0x5, 0xeb, 0x27, 0x4e, 0x16, 0x5e, 0xf3, 0xb2, 0x8b, 0x47, 0xd1, 0xe6, 0x94, 0x7e, 0x8b}, + Metadata: types.Metadata{ + ChunkHashes: checksums(expectChunks), + }, + }, snapshot) + + storeSnapshot, chunks, err := store.Load(snapshot.Height, snapshot.Format) + require.NoError(t, err) + assert.Equal(t, snapshot, storeSnapshot) + assert.Equal(t, expectChunks, readChunks(chunks)) + + err = manager.Restore(*snapshot) + require.NoError(t, err) + + // Feeding the chunks should work + for i, chunk := range readChunks(chunks) { + done, err := manager.RestoreChunk(chunk) + require.NoError(t, err) + if i == len(chunks)-1 { + assert.True(t, done) + } else { + assert.False(t, done) + } + } + + // The snapshot is saved in local snapshot store + snapshots, err := store.List() + require.NoError(t, err) + require.Equal(t, uint64(5), snapshots[0].Height) + require.Equal(t, types.CurrentFormat, snapshots[0].Format) + + // Starting a new restore should fail now, because the target already has contents. + err = manager.Restore(*snapshot) + require.Error(t, err) + + storeSnapshot, chunks, err = store.Load(snapshot.Height, snapshot.Format) + require.NoError(t, err) + assert.Equal(t, snapshot, storeSnapshot) + assert.Equal(t, expectChunks, readChunks(chunks)) + + // Feeding the chunks should work + for i, chunk := range readChunks(chunks) { + done, err := manager.RestoreChunk(chunk) + require.NoError(t, err) + if i == len(chunks)-1 { + assert.True(t, done) + } else { + assert.False(t, done) + } + } + + assert.Equal(t, items, commitSnapshotter.items) + assert.Equal(t, 10, len(extSnapshotter.state)) + + snapshots, err = store.List() + require.NoError(t, err) + require.Equal(t, uint64(5), snapshots[0].Height) + require.Equal(t, types.CurrentFormat, snapshots[0].Format) +} + +func TestSnapshot_Take_Prune(t *testing.T) { + store := setupStore(t) + + items := [][]byte{ + {1, 2, 3}, + {4, 5, 6}, + {7, 8, 9}, + } + commitSnapshotter := &mockCommitSnapshotter{ + items: items, + } + extSnapshotter := newExtSnapshotter(10) + + expectChunks := snapshotItems(items, extSnapshotter) + manager := snapshots.NewManager(store, opts, commitSnapshotter, &mockStorageSnapshotter{}, nil, log.NewNopLogger()) + err := manager.RegisterExtensions(extSnapshotter) + require.NoError(t, err) + + // creating a snapshot at height 4 + snapshot, err := manager.Create(4) + require.NoError(t, err) + + assert.Equal(t, &types.Snapshot{ + Height: 4, + Format: commitSnapshotter.SnapshotFormat(), + Chunks: 1, + Hash: []uint8{0xc5, 0xf7, 0xfe, 0xea, 0xd3, 0x4d, 0x3e, 0x87, 0xff, 0x41, 0xa2, 0x27, 0xfa, 0xcb, 0x38, 0x17, 0xa, 0x5, 0xeb, 0x27, 0x4e, 0x16, 0x5e, 0xf3, 0xb2, 0x8b, 0x47, 0xd1, 0xe6, 0x94, 0x7e, 0x8b}, + Metadata: types.Metadata{ + ChunkHashes: checksums(expectChunks), + }, + }, snapshot) + + pruned, err := manager.Prune(1) + require.NoError(t, err) + assert.EqualValues(t, 4, pruned) + + // creating a snapshot at a same height 4, should be error + // since we prune all the previous snapshot except the latest at height 4 + _, err = manager.Create(4) + require.Error(t, err) + + // prune all + pruned, err = manager.Prune(0) + require.NoError(t, err) + assert.EqualValues(t, 1, pruned) + + // creating a snapshot at a same height 4, should be true since we prune all the previous snapshot + snapshot, err = manager.Create(4) + require.NoError(t, err) + + assert.Equal(t, &types.Snapshot{ + Height: 4, + Format: commitSnapshotter.SnapshotFormat(), + Chunks: 1, + Hash: []uint8{0xc5, 0xf7, 0xfe, 0xea, 0xd3, 0x4d, 0x3e, 0x87, 0xff, 0x41, 0xa2, 0x27, 0xfa, 0xcb, 0x38, 0x17, 0xa, 0x5, 0xeb, 0x27, 0x4e, 0x16, 0x5e, 0xf3, 0xb2, 0x8b, 0x47, 0xd1, 0xe6, 0x94, 0x7e, 0x8b}, + Metadata: types.Metadata{ + ChunkHashes: checksums(expectChunks), + }, + }, snapshot) + + storeSnapshot, chunks, err := store.Load(snapshot.Height, snapshot.Format) + require.NoError(t, err) + assert.Equal(t, snapshot, storeSnapshot) + assert.Equal(t, expectChunks, readChunks(chunks)) + + pruned, err = manager.Prune(2) + require.NoError(t, err) + assert.EqualValues(t, 0, pruned) + + list, err := manager.List() + require.NoError(t, err) + assert.Len(t, list, 1) + + // Prune should error while a snapshot is being taken + manager = setupBusyManager(t) + _, err = manager.Prune(2) + require.Error(t, err) +} From 8fe0b22145806cfc196c776418eece72d122a853 Mon Sep 17 00:00:00 2001 From: lfz941 Date: Mon, 22 Jul 2024 18:16:07 +0800 Subject: [PATCH 21/50] docs(server): wrong function comments (#21017) --- server/v2/cometbft/abci.go | 2 +- server/v2/config.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/server/v2/cometbft/abci.go b/server/v2/cometbft/abci.go index ad69cf9a941d..b0c1a8452a13 100644 --- a/server/v2/cometbft/abci.go +++ b/server/v2/cometbft/abci.go @@ -103,7 +103,7 @@ func (c *Consensus[T]) SetStreamingManager(sm streaming.Manager) { c.streaming = sm } -// RegisterExtensions registers the given extensions with the consensus module's snapshot manager. +// RegisterSnapshotExtensions registers the given extensions with the consensus module's snapshot manager. // It allows additional snapshotter implementations to be used for creating and restoring snapshots. func (c *Consensus[T]) RegisterSnapshotExtensions(extensions ...snapshots.ExtensionSnapshotter) error { if err := c.snapshotManager.RegisterExtensions(extensions...); err != nil { diff --git a/server/v2/config.go b/server/v2/config.go index 5a5936718929..57cce302bd74 100644 --- a/server/v2/config.go +++ b/server/v2/config.go @@ -28,7 +28,7 @@ func ReadConfig(configPath string) (*viper.Viper, error) { return v, nil } -// UnmarshalSubconfig unmarshals the given subconfig from the viper instance. +// UnmarshalSubConfig unmarshals the given subconfig from the viper instance. // It unmarshals the config, env, flags into the target struct. // Use this instead of viper.Sub because viper does not unmarshal flags. func UnmarshalSubConfig(v *viper.Viper, subName string, target any) error { From 71d14f93702978c53c090051916b255a7d7f0c0a Mon Sep 17 00:00:00 2001 From: Akhil Kumar P <36399231+akhilkumarpilli@users.noreply.github.com> Date: Mon, 22 Jul 2024 16:10:17 +0530 Subject: [PATCH 22/50] chore(server/v2/cometbft): ensure consistent dash-case in app.toml (#21018) --- server/v2/cometbft/config.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/server/v2/cometbft/config.go b/server/v2/cometbft/config.go index d04082972434..3f03e383c601 100644 --- a/server/v2/cometbft/config.go +++ b/server/v2/cometbft/config.go @@ -27,10 +27,10 @@ func DefaultAppTomlConfig() *AppTomlConfig { } type AppTomlConfig struct { - MinRetainBlocks uint64 `mapstructure:"min_retain_blocks" toml:"min_retain_blocks" comment:"min_retain_blocks defines the minimum block height offset from the current block being committed, such that all blocks past this offset are pruned from CometBFT. A value of 0 indicates that no blocks should be pruned."` - IndexEvents []string `mapstructure:"index_events" toml:"index_events" comment:"index_events defines the set of events in the form {eventType}.{attributeKey}, which informs CometBFT what to index. If empty, all events will be indexed."` - HaltHeight uint64 `mapstructure:"halt_height" toml:"halt_height" comment:"halt_height contains a non-zero block height at which a node will gracefully halt and shutdown that can be used to assist upgrades and testing."` - HaltTime uint64 `mapstructure:"halt_time" toml:"halt_time" comment:"halt_time contains a non-zero minimum block time (in Unix seconds) at which a node will gracefully halt and shutdown that can be used to assist upgrades and testing."` + MinRetainBlocks uint64 `mapstructure:"min-retain-blocks" toml:"min-retain-blocks" comment:"min-retain-blocks defines the minimum block height offset from the current block being committed, such that all blocks past this offset are pruned from CometBFT. A value of 0 indicates that no blocks should be pruned."` + IndexEvents []string `mapstructure:"index-events" toml:"index-events" comment:"index-events defines the set of events in the form {eventType}.{attributeKey}, which informs CometBFT what to index. If empty, all events will be indexed."` + HaltHeight uint64 `mapstructure:"halt-height" toml:"halt-height" comment:"halt-height contains a non-zero block height at which a node will gracefully halt and shutdown that can be used to assist upgrades and testing."` + HaltTime uint64 `mapstructure:"halt-time" toml:"halt-time" comment:"halt-time contains a non-zero minimum block time (in Unix seconds) at which a node will gracefully halt and shutdown that can be used to assist upgrades and testing."` Address string `mapstructure:"address" toml:"address" comment:"address defines the CometBFT RPC server address to bind to."` Transport string `mapstructure:"transport" toml:"transport" comment:"transport defines the CometBFT RPC server transport protocol: socket, grpc"` Trace bool `mapstructure:"trace" toml:"trace" comment:"trace enables the CometBFT RPC server to output trace information about its internal operations."` From 9ab162de6d686bc63aac9f41241b0782dc02b1e8 Mon Sep 17 00:00:00 2001 From: Facundo Medica <14063057+facundomedica@users.noreply.github.com> Date: Mon, 22 Jul 2024 13:23:51 +0200 Subject: [PATCH 23/50] chore(all)!: use gogoproto/any instead of codec/types/any (#21013) --- UPGRADING.md | 4 +- client/grpc/cmtservice/service.go | 7 +-- client/keys/output_test.go | 23 ++++++++++ codec/codec.go | 3 +- codec/types/interface_registry.go | 44 ++----------------- crypto/keyring/legacy_info.go | 4 +- crypto/keyring/record.go | 4 +- crypto/keys/multisig/multisig.go | 12 ++--- .../client/grpc/cmtservice/service.go | 10 ++--- testutil/testdata/animal.go | 15 +++---- testutil/testdata/grpc_query.go | 9 ++-- types/result.go | 7 +-- types/tx/direct_aux.go | 7 +-- types/tx/ext.go | 4 +- types/tx/msgs.go | 4 +- types/tx/signing/signature.go | 9 ++-- types/tx/types.go | 12 ++--- x/auth/migrations/legacytx/stdsign.go | 3 +- x/auth/migrations/legacytx/stdsignmsg.go | 6 ++- x/auth/migrations/legacytx/stdtx.go | 8 ++-- x/auth/types/account.go | 14 +++--- x/auth/types/genesis.go | 5 ++- x/auth/types/query.go | 7 +-- x/authz/authorization_grant.go | 8 ++-- x/authz/genesis.go | 8 ++-- x/authz/msgs.go | 11 ++--- x/authz/simulation/operations.go | 4 +- x/evidence/types/genesis.go | 5 ++- x/evidence/types/genesis_test.go | 3 +- x/evidence/types/msgs.go | 9 ++-- x/feegrant/filtered_fee.go | 7 +-- x/feegrant/genesis.go | 6 +-- x/feegrant/grant.go | 5 ++- x/feegrant/msgs.go | 7 +-- x/gov/types/v1/genesis.go | 7 ++- x/gov/types/v1/msgs.go | 10 +++-- x/gov/types/v1/proposal.go | 9 ++-- x/gov/types/v1beta1/genesis.go | 8 ++-- x/gov/types/v1beta1/msgs.go | 5 ++- x/gov/types/v1beta1/proposal.go | 7 +-- x/group/genesis.go | 5 ++- x/group/msgs.go | 15 ++++--- x/group/proposal.go | 5 ++- x/group/simulation/operations.go | 4 +- x/group/types.go | 9 ++-- x/staking/types/genesis.go | 5 ++- x/staking/types/msg.go | 24 +++++----- x/staking/types/validator.go | 6 ++- 48 files changed, 222 insertions(+), 191 deletions(-) diff --git a/UPGRADING.md b/UPGRADING.md index 887fb2a1e454..5f96b53ed535 100644 --- a/UPGRADING.md +++ b/UPGRADING.md @@ -170,7 +170,9 @@ There is no longer a need for the Cosmos SDK to host these protos for itself and That package containing proto v2 generated code, but the SDK now uses [buf generated go SDK instead](https://buf.build/docs/bsr/generated-sdks/go). If you were depending on `cosmossdk.io/api/tendermint`, please use the buf generated go SDK instead, or ask CometBFT host the generated proto v2 code. -The `codectypes.Any` has moved to `github.com/cosmos/gogoproto/types/any`. Module developers can update the `buf.gen.gogo.yaml` configuration files by adjusting the corresponding `opt` option to `Mgoogle/protobuf/any.proto=github.com/cosmos/gogoproto/types/any` for directly mapping the`Any` type to its new location. This change is optional as `codectypes.Any` is aliased to `gogoproto.Any` in the SDK. +The `codectypes.Any` has moved to `github.com/cosmos/gogoproto/types/any`. Module developers need to update the `buf.gen.gogo.yaml` configuration files by adjusting the corresponding `opt` option to `Mgoogle/protobuf/any.proto=github.com/cosmos/gogoproto/types/any` for directly mapping the`Any` type to its new location. This change is optional, but recommended, as `codectypes.Any` is aliased to `gogoproto.Any` in the SDK. + +Also, any usages of the interfaces `AnyUnpacker` and `UnpackInterfacesMessage` must be replaced with the interfaces of the same name in the `github.com/cosmos/gogoproto/types/any` package. ### Modules diff --git a/client/grpc/cmtservice/service.go b/client/grpc/cmtservice/service.go index ad307984c0e5..05eeeb6ecc43 100644 --- a/client/grpc/cmtservice/service.go +++ b/client/grpc/cmtservice/service.go @@ -5,6 +5,7 @@ import ( abci "github.com/cometbft/cometbft/api/cometbft/abci/v1" gogogrpc "github.com/cosmos/gogoproto/grpc" + gogoprotoany "github.com/cosmos/gogoproto/types/any" "github.com/grpc-ecosystem/grpc-gateway/runtime" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" @@ -20,8 +21,8 @@ import ( ) var ( - _ ServiceServer = queryServer{} - _ codectypes.UnpackInterfacesMessage = &GetLatestValidatorSetResponse{} + _ ServiceServer = queryServer{} + _ gogoprotoany.UnpackInterfacesMessage = &GetLatestValidatorSetResponse{} ) type ( @@ -112,7 +113,7 @@ func (s queryServer) GetLatestValidatorSet(ctx context.Context, req *GetLatestVa return ValidatorsOutput(ctx, s.clientCtx, nil, page, limit) } -func (m *GetLatestValidatorSetResponse) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { +func (m *GetLatestValidatorSetResponse) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { var pubKey cryptotypes.PubKey for _, val := range m.Validators { err := unpacker.UnpackAny(val.PubKey, &pubKey) diff --git a/client/keys/output_test.go b/client/keys/output_test.go index c88f93b8752a..b56a30c7a083 100644 --- a/client/keys/output_test.go +++ b/client/keys/output_test.go @@ -8,6 +8,7 @@ import ( "github.com/cosmos/cosmos-sdk/codec" addresscodec "github.com/cosmos/cosmos-sdk/codec/address" + codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil" codectypes "github.com/cosmos/cosmos-sdk/codec/types" cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" "github.com/cosmos/cosmos-sdk/crypto/keyring" @@ -15,6 +16,7 @@ import ( "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" "github.com/cosmos/cosmos-sdk/crypto/types" sdk "github.com/cosmos/cosmos-sdk/types" + moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil" ) func generatePubKeys(n int) []types.PubKey { @@ -100,3 +102,24 @@ func TestProtoMarshalJSON(t *testing.T) { require.Equal(ko.Address, expectedOutput) require.Equal(ko.PubKey, string(bz)) } + +func TestNestedMultisigOutput(t *testing.T) { + cdc := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}).Codec + + sk := secp256k1.PrivKey{Key: []byte{154, 49, 3, 117, 55, 232, 249, 20, 205, 216, 102, 7, 136, 72, 177, 2, 131, 202, 234, 81, 31, 208, 46, 244, 179, 192, 167, 163, 142, 117, 246, 13}} + tmpKey := sk.PubKey() + multisigPk := kmultisig.NewLegacyAminoPubKey(1, []types.PubKey{tmpKey}) + multisigPk2 := kmultisig.NewLegacyAminoPubKey(1, []types.PubKey{tmpKey, multisigPk}) + + kb, err := keyring.New(t.Name(), keyring.BackendTest, t.TempDir(), nil, cdc) + require.NoError(t, err) + + _, err = kb.SaveMultisig("multisig", multisigPk2) + require.NoError(t, err) + + k, err := kb.Key("multisig") + require.NoError(t, err) + + _, err = MkAccKeyOutput(k, addresscodec.NewBech32Codec("cosmos")) + require.NoError(t, err) +} diff --git a/codec/codec.go b/codec/codec.go index c8c5844ac04b..3d9cfd771bc0 100644 --- a/codec/codec.go +++ b/codec/codec.go @@ -2,6 +2,7 @@ package codec import ( "github.com/cosmos/gogoproto/proto" + gogoprotoany "github.com/cosmos/gogoproto/types/any" "google.golang.org/grpc/encoding" "google.golang.org/protobuf/reflect/protoreflect" @@ -76,7 +77,7 @@ type ( // is not registered in codec, or is not compatible with the serialized data UnmarshalInterface(bz []byte, ptr interface{}) error - types.AnyUnpacker + gogoprotoany.AnyUnpacker } JSONCodec interface { diff --git a/codec/types/interface_registry.go b/codec/types/interface_registry.go index 63bcc8094b43..04c94c4394a9 100644 --- a/codec/types/interface_registry.go +++ b/codec/types/interface_registry.go @@ -7,6 +7,7 @@ import ( "github.com/cosmos/gogoproto/jsonpb" "github.com/cosmos/gogoproto/proto" + gogoprotoany "github.com/cosmos/gogoproto/types/any" "google.golang.org/protobuf/reflect/protodesc" "google.golang.org/protobuf/reflect/protoreflect" @@ -14,47 +15,10 @@ import ( "cosmossdk.io/x/tx/signing" ) -// AnyUnpacker is an interface which allows safely unpacking types packed -// in Any's against a whitelist of registered types -type AnyUnpacker interface { - // UnpackAny unpacks the value in any to the interface pointer passed in as - // iface. Note that the type in any must have been registered in the - // underlying whitelist registry as a concrete type for that interface - // Ex: - // var msg sdk.Msg - // err := cdc.UnpackAny(any, &msg) - // ... - UnpackAny(any *Any, iface interface{}) error -} - -// UnpackInterfacesMessage is meant to extend protobuf types (which implement -// proto.Message) to support a post-deserialization phase which unpacks -// types packed within Any's using the whitelist provided by AnyUnpacker -type UnpackInterfacesMessage interface { - // UnpackInterfaces is implemented in order to unpack values packed within - // Any's using the AnyUnpacker. It should generally be implemented as - // follows: - // func (s *MyStruct) UnpackInterfaces(unpacker AnyUnpacker) error { - // var x AnyInterface - // // where X is an Any field on MyStruct - // err := unpacker.UnpackAny(s.X, &x) - // if err != nil { - // return nil - // } - // // where Y is a field on MyStruct that implements UnpackInterfacesMessage itself - // err = s.Y.UnpackInterfaces(unpacker) - // if err != nil { - // return nil - // } - // return nil - // } - UnpackInterfaces(unpacker AnyUnpacker) error -} - // UnpackInterfaces is a convenience function that calls UnpackInterfaces // on x if x implements UnpackInterfacesMessage -func UnpackInterfaces(x interface{}, unpacker AnyUnpacker) error { - if msg, ok := x.(UnpackInterfacesMessage); ok { +func UnpackInterfaces(x interface{}, unpacker gogoprotoany.AnyUnpacker) error { + if msg, ok := x.(gogoprotoany.UnpackInterfacesMessage); ok { return msg.UnpackInterfaces(unpacker) } return nil @@ -65,7 +29,7 @@ var protoMessageType = reflect.TypeOf((*proto.Message)(nil)).Elem() // InterfaceRegistry provides a mechanism for registering interfaces and // implementations that can be safely unpacked from Any type InterfaceRegistry interface { - AnyUnpacker + gogoprotoany.AnyUnpacker jsonpb.AnyResolver registry.InterfaceRegistrar diff --git a/crypto/keyring/legacy_info.go b/crypto/keyring/legacy_info.go index 47cbe3e9a920..48e5d664f11f 100644 --- a/crypto/keyring/legacy_info.go +++ b/crypto/keyring/legacy_info.go @@ -4,6 +4,8 @@ import ( "errors" "fmt" + gogoprotoany "github.com/cosmos/gogoproto/types/any" + "github.com/cosmos/cosmos-sdk/codec/legacy" codectypes "github.com/cosmos/cosmos-sdk/codec/types" "github.com/cosmos/cosmos-sdk/crypto/hd" @@ -218,7 +220,7 @@ func (i LegacyMultiInfo) GetPath() (*hd.BIP44Params, error) { } // UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces -func (i LegacyMultiInfo) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { +func (i LegacyMultiInfo) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { multiPK := i.PubKey.(*multisig.LegacyAminoPubKey) return codectypes.UnpackInterfaces(multiPK, unpacker) diff --git a/crypto/keyring/record.go b/crypto/keyring/record.go index 96141e4c906e..2e19c5b91576 100644 --- a/crypto/keyring/record.go +++ b/crypto/keyring/record.go @@ -3,6 +3,8 @@ package keyring import ( "errors" + gogoprotoany "github.com/cosmos/gogoproto/types/any" + errorsmod "cosmossdk.io/errors" codectypes "github.com/cosmos/cosmos-sdk/codec/types" @@ -103,7 +105,7 @@ func (k Record) GetType() KeyType { } // UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces -func (k *Record) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { +func (k *Record) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { var pk cryptotypes.PubKey if err := unpacker.UnpackAny(k.PubKey, &pk); err != nil { return err diff --git a/crypto/keys/multisig/multisig.go b/crypto/keys/multisig/multisig.go index 623f25516164..1fc3f8e28098 100644 --- a/crypto/keys/multisig/multisig.go +++ b/crypto/keys/multisig/multisig.go @@ -4,6 +4,7 @@ import ( "fmt" cmtcrypto "github.com/cometbft/cometbft/crypto" + gogoprotoany "github.com/cosmos/gogoproto/types/any" "github.com/cosmos/cosmos-sdk/codec/types" cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" @@ -12,8 +13,8 @@ import ( ) var ( - _ multisigtypes.PubKey = &LegacyAminoPubKey{} - _ types.UnpackInterfacesMessage = &LegacyAminoPubKey{} + _ multisigtypes.PubKey = &LegacyAminoPubKey{} + _ gogoprotoany.UnpackInterfacesMessage = &LegacyAminoPubKey{} ) // NewLegacyAminoPubKey returns a new LegacyAminoPubKey. @@ -149,7 +150,7 @@ func (m *LegacyAminoPubKey) Type() string { } // UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces -func (m *LegacyAminoPubKey) UnpackInterfaces(unpacker types.AnyUnpacker) error { +func (m *LegacyAminoPubKey) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { for _, any := range m.PubKeys { var pk cryptotypes.PubKey err := unpacker.UnpackAny(any, &pk) @@ -169,11 +170,6 @@ func packPubKeys(pubKeys []cryptotypes.PubKey) ([]*types.Any, error) { return nil, err } anyPubKeys[i] = any - - // sets the compat.aminoBz value - if err := anyPubKeys[i].UnmarshalAmino(pubKeys[i].Bytes()); err != nil { - return nil, err - } } return anyPubKeys, nil } diff --git a/server/v2/cometbft/client/grpc/cmtservice/service.go b/server/v2/cometbft/client/grpc/cmtservice/service.go index 426b32aa45d4..3e0188c2a7e9 100644 --- a/server/v2/cometbft/client/grpc/cmtservice/service.go +++ b/server/v2/cometbft/client/grpc/cmtservice/service.go @@ -4,15 +4,15 @@ import ( "context" "strings" + "cosmossdk.io/server/v2/cometbft/client/rpc" abci "github.com/cometbft/cometbft/api/cometbft/abci/v1" coretypes "github.com/cometbft/cometbft/rpc/core/types" gogogrpc "github.com/cosmos/gogoproto/grpc" + gogoprotoany "github.com/cosmos/gogoproto/types/any" "github.com/grpc-ecosystem/grpc-gateway/runtime" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" - "cosmossdk.io/server/v2/cometbft/client/rpc" - codectypes "github.com/cosmos/cosmos-sdk/codec/types" cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" @@ -22,8 +22,8 @@ import ( ) var ( - _ ServiceServer = queryServer{} - _ codectypes.UnpackInterfacesMessage = &GetLatestValidatorSetResponse{} + _ ServiceServer = queryServer{} + _ gogoprotoany.UnpackInterfacesMessage = &GetLatestValidatorSetResponse{} ) const ( @@ -136,7 +136,7 @@ func (s queryServer) GetLatestValidatorSet( return ValidatorsOutput(ctx, s.client, nil, page, limit) } -func (m *GetLatestValidatorSetResponse) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { +func (m *GetLatestValidatorSetResponse) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { var pubKey cryptotypes.PubKey for _, val := range m.Validators { err := unpacker.UnpackAny(val.PubKey, &pubKey) diff --git a/testutil/testdata/animal.go b/testutil/testdata/animal.go index 7d5afa615280..327b8851e1ea 100644 --- a/testutil/testdata/animal.go +++ b/testutil/testdata/animal.go @@ -4,8 +4,7 @@ import ( "fmt" "github.com/cosmos/gogoproto/proto" - - "github.com/cosmos/cosmos-sdk/codec/types" + gogoprotoany "github.com/cosmos/gogoproto/types/any" ) type Animal interface { @@ -32,9 +31,9 @@ func (d Dog) Greet() string { return fmt.Sprintf("Roof, my name is %s", d.Name) } -var _ types.UnpackInterfacesMessage = HasAnimal{} +var _ gogoprotoany.UnpackInterfacesMessage = HasAnimal{} -func (m HasAnimal) UnpackInterfaces(unpacker types.AnyUnpacker) error { +func (m HasAnimal) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { var animal Animal return unpacker.UnpackAny(m.Animal, &animal) } @@ -59,9 +58,9 @@ func (m HasHasAnimal) TheHasAnimal() HasAnimalI { return m.HasAnimal.GetCachedValue().(HasAnimalI) } -var _ types.UnpackInterfacesMessage = HasHasAnimal{} +var _ gogoprotoany.UnpackInterfacesMessage = HasHasAnimal{} -func (m HasHasAnimal) UnpackInterfaces(unpacker types.AnyUnpacker) error { +func (m HasHasAnimal) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { var animal HasAnimalI return unpacker.UnpackAny(m.HasAnimal, &animal) } @@ -76,9 +75,9 @@ func (m HasHasHasAnimal) TheHasHasAnimal() HasHasAnimalI { return m.HasHasAnimal.GetCachedValue().(HasHasAnimalI) } -var _ types.UnpackInterfacesMessage = HasHasHasAnimal{} +var _ gogoprotoany.UnpackInterfacesMessage = HasHasHasAnimal{} -func (m HasHasHasAnimal) UnpackInterfaces(unpacker types.AnyUnpacker) error { +func (m HasHasHasAnimal) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { var animal HasHasAnimalI return unpacker.UnpackAny(m.HasHasAnimal, &animal) } diff --git a/testutil/testdata/grpc_query.go b/testutil/testdata/grpc_query.go index 1078f60b8b81..d4ca6c73d888 100644 --- a/testutil/testdata/grpc_query.go +++ b/testutil/testdata/grpc_query.go @@ -5,6 +5,7 @@ import ( "fmt" "testing" + gogoprotoany "github.com/cosmos/gogoproto/types/any" "github.com/cosmos/gogoproto/types/any/test" "github.com/cosmos/gogoproto/proto" @@ -49,16 +50,16 @@ func (e QueryImpl) SayHello(_ context.Context, request *SayHelloRequest) (*SayHe return &SayHelloResponse{Greeting: greeting}, nil } -var _ types.UnpackInterfacesMessage = &TestAnyRequest{} +var _ gogoprotoany.UnpackInterfacesMessage = &TestAnyRequest{} -func (m *TestAnyRequest) UnpackInterfaces(unpacker types.AnyUnpacker) error { +func (m *TestAnyRequest) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { var animal test.Animal return unpacker.UnpackAny(m.AnyAnimal, &animal) } -var _ types.UnpackInterfacesMessage = &TestAnyResponse{} +var _ gogoprotoany.UnpackInterfacesMessage = &TestAnyResponse{} -func (m *TestAnyResponse) UnpackInterfaces(unpacker types.AnyUnpacker) error { +func (m *TestAnyResponse) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { return m.HasAnimal.UnpackInterfaces(unpacker) } diff --git a/types/result.go b/types/result.go index 148847eecf2b..b4724151e9da 100644 --- a/types/result.go +++ b/types/result.go @@ -7,6 +7,7 @@ import ( cmtproto "github.com/cometbft/cometbft/api/cometbft/types/v1" coretypes "github.com/cometbft/cometbft/rpc/core/types" + gogoprotoany "github.com/cosmos/gogoproto/types/any" "github.com/cosmos/cosmos-sdk/codec" codectypes "github.com/cosmos/cosmos-sdk/codec/types" @@ -159,13 +160,13 @@ func ParseABCILogs(logs string) (res ABCIMessageLogs, err error) { return res, err } -var _, _ codectypes.UnpackInterfacesMessage = SearchTxsResult{}, TxResponse{} +var _, _ gogoprotoany.UnpackInterfacesMessage = SearchTxsResult{}, TxResponse{} // UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces // // types.UnpackInterfaces needs to be called for each nested Tx because // there are generally interfaces to unpack in Tx's -func (s SearchTxsResult) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { +func (s SearchTxsResult) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { for _, tx := range s.Txs { err := codectypes.UnpackInterfaces(tx, unpacker) if err != nil { @@ -176,7 +177,7 @@ func (s SearchTxsResult) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error } // UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces -func (r TxResponse) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { +func (r TxResponse) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { if r.Tx != nil { var tx HasMsgs return unpacker.UnpackAny(r.Tx, &tx) diff --git a/types/tx/direct_aux.go b/types/tx/direct_aux.go index 52c9fc214a8e..d685a837ad29 100644 --- a/types/tx/direct_aux.go +++ b/types/tx/direct_aux.go @@ -1,7 +1,8 @@ package tx import ( - codectypes "github.com/cosmos/cosmos-sdk/codec/types" + gogoprotoany "github.com/cosmos/gogoproto/types/any" + cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/cosmos/cosmos-sdk/types/tx/signing" @@ -21,7 +22,7 @@ func (s *SignDocDirectAux) ValidateBasic() error { } // UnpackInterfaces implements the UnpackInterfaceMessages.UnpackInterfaces method -func (s *SignDocDirectAux) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { +func (s *SignDocDirectAux) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { return unpacker.UnpackAny(s.PublicKey, new(cryptotypes.PubKey)) } @@ -60,6 +61,6 @@ func (a *AuxSignerData) GetSignatureV2() (signing.SignatureV2, error) { } // UnpackInterfaces implements the UnpackInterfaceMessages.UnpackInterfaces method -func (a *AuxSignerData) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { +func (a *AuxSignerData) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { return a.GetSignDoc().UnpackInterfaces(unpacker) } diff --git a/types/tx/ext.go b/types/tx/ext.go index fb2e1ed448bc..e51be337d5b1 100644 --- a/types/tx/ext.go +++ b/types/tx/ext.go @@ -1,6 +1,8 @@ package tx import ( + gogoprotoany "github.com/cosmos/gogoproto/types/any" + "github.com/cosmos/cosmos-sdk/codec/types" ) @@ -8,7 +10,7 @@ import ( type TxExtensionOptionI interface{} // unpackTxExtensionOptionsI unpacks Any's to TxExtensionOptionI's. -func unpackTxExtensionOptionsI(unpacker types.AnyUnpacker, anys []*types.Any) error { +func unpackTxExtensionOptionsI(unpacker gogoprotoany.AnyUnpacker, anys []*types.Any) error { for _, any := range anys { var opt TxExtensionOptionI err := unpacker.UnpackAny(any, &opt) diff --git a/types/tx/msgs.go b/types/tx/msgs.go index 2f2f9a80f912..036f9a2414c8 100644 --- a/types/tx/msgs.go +++ b/types/tx/msgs.go @@ -3,6 +3,8 @@ package tx import ( "fmt" + gogoprotoany "github.com/cosmos/gogoproto/types/any" + "github.com/cosmos/cosmos-sdk/codec/types" sdk "github.com/cosmos/cosmos-sdk/types" ) @@ -53,7 +55,7 @@ func GetMsgs(anys []*types.Any, name string) ([]sdk.Msg, error) { } // UnpackInterfaces unpacks Any's to sdk.Msg's. -func UnpackInterfaces(unpacker types.AnyUnpacker, anys []*types.Any) error { +func UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker, anys []*types.Any) error { for _, any := range anys { var msg sdk.Msg err := unpacker.UnpackAny(any, &msg) diff --git a/types/tx/signing/signature.go b/types/tx/signing/signature.go index a9549bab9a12..a27ea27b86eb 100644 --- a/types/tx/signing/signature.go +++ b/types/tx/signing/signature.go @@ -3,7 +3,8 @@ package signing import ( "fmt" - codectypes "github.com/cosmos/cosmos-sdk/codec/types" + gogoprotoany "github.com/cosmos/gogoproto/types/any" + cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" ) @@ -86,10 +87,10 @@ func SignatureDataFromProto(descData *SignatureDescriptor_Data) SignatureData { } } -var _, _ codectypes.UnpackInterfacesMessage = &SignatureDescriptors{}, &SignatureDescriptor{} +var _, _ gogoprotoany.UnpackInterfacesMessage = &SignatureDescriptors{}, &SignatureDescriptor{} // UnpackInterfaces implements the UnpackInterfaceMessages.UnpackInterfaces method -func (sds *SignatureDescriptors) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { +func (sds *SignatureDescriptors) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { for _, sig := range sds.Signatures { err := sig.UnpackInterfaces(unpacker) if err != nil { @@ -101,6 +102,6 @@ func (sds *SignatureDescriptors) UnpackInterfaces(unpacker codectypes.AnyUnpacke } // UnpackInterfaces implements the UnpackInterfaceMessages.UnpackInterfaces method -func (sd *SignatureDescriptor) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { +func (sd *SignatureDescriptor) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { return unpacker.UnpackAny(sd.PublicKey, new(cryptotypes.PubKey)) } diff --git a/types/tx/types.go b/types/tx/types.go index b2726c60abf2..b8a61946538c 100644 --- a/types/tx/types.go +++ b/types/tx/types.go @@ -3,13 +3,13 @@ package tx import ( "errors" + gogoprotoany "github.com/cosmos/gogoproto/types/any" "google.golang.org/protobuf/reflect/protoreflect" "cosmossdk.io/core/registry" errorsmod "cosmossdk.io/errors" "github.com/cosmos/cosmos-sdk/codec" - codectypes "github.com/cosmos/cosmos-sdk/codec/types" cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" @@ -20,7 +20,7 @@ const MaxGasWanted = uint64((1 << 63) - 1) // Interface implementation checks. var ( - _, _, _, _ codectypes.UnpackInterfacesMessage = &Tx{}, &TxBody{}, &AuthInfo{}, &SignerInfo{} + _, _, _, _ gogoprotoany.UnpackInterfacesMessage = &Tx{}, &TxBody{}, &AuthInfo{}, &SignerInfo{} ) // GetMsgs implements the GetMsgs method on sdk.Tx. @@ -177,7 +177,7 @@ func (t *Tx) FeeGranter(cdc codec.Codec) []byte { } // UnpackInterfaces implements the UnpackInterfaceMessages.UnpackInterfaces method -func (t *Tx) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { +func (t *Tx) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { if t.Body != nil { if err := t.Body.UnpackInterfaces(unpacker); err != nil { return err @@ -192,7 +192,7 @@ func (t *Tx) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { } // UnpackInterfaces implements the UnpackInterfaceMessages.UnpackInterfaces method -func (m *TxBody) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { +func (m *TxBody) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { if err := UnpackInterfaces(unpacker, m.Messages); err != nil { return err } @@ -209,7 +209,7 @@ func (m *TxBody) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { } // UnpackInterfaces implements the UnpackInterfaceMessages.UnpackInterfaces method -func (m *AuthInfo) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { +func (m *AuthInfo) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { for _, signerInfo := range m.SignerInfos { err := signerInfo.UnpackInterfaces(unpacker) if err != nil { @@ -220,7 +220,7 @@ func (m *AuthInfo) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { } // UnpackInterfaces implements the UnpackInterfaceMessages.UnpackInterfaces method -func (m *SignerInfo) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { +func (m *SignerInfo) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { return unpacker.UnpackAny(m.PublicKey, new(cryptotypes.PubKey)) } diff --git a/x/auth/migrations/legacytx/stdsign.go b/x/auth/migrations/legacytx/stdsign.go index 71887fb26c99..6ef08f4c8a02 100644 --- a/x/auth/migrations/legacytx/stdsign.go +++ b/x/auth/migrations/legacytx/stdsign.go @@ -5,6 +5,7 @@ import ( "errors" "fmt" + gogoprotoany "github.com/cosmos/gogoproto/types/any" "sigs.k8s.io/yaml" errorsmod "cosmossdk.io/errors" @@ -130,7 +131,7 @@ func (ss StdSignature) MarshalYAML() (interface{}, error) { return string(bz), err } -func (ss StdSignature) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { +func (ss StdSignature) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { return codectypes.UnpackInterfaces(ss.PubKey, unpacker) } diff --git a/x/auth/migrations/legacytx/stdsignmsg.go b/x/auth/migrations/legacytx/stdsignmsg.go index 561a64463f50..1fd8c585015f 100644 --- a/x/auth/migrations/legacytx/stdsignmsg.go +++ b/x/auth/migrations/legacytx/stdsignmsg.go @@ -1,11 +1,13 @@ package legacytx import ( + gogoprotoany "github.com/cosmos/gogoproto/types/any" + "github.com/cosmos/cosmos-sdk/codec/types" sdk "github.com/cosmos/cosmos-sdk/types" ) -var _ types.UnpackInterfacesMessage = StdSignMsg{} +var _ gogoprotoany.UnpackInterfacesMessage = StdSignMsg{} // StdSignMsg is a convenience structure for passing along a Msg with the other // requirements for a StdSignDoc before it is signed. For use in the CLI. @@ -19,7 +21,7 @@ type StdSignMsg struct { Memo string `json:"memo" yaml:"memo"` } -func (msg StdSignMsg) UnpackInterfaces(unpacker types.AnyUnpacker) error { +func (msg StdSignMsg) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { for _, m := range msg.Msgs { err := types.UnpackInterfaces(m, unpacker) if err != nil { diff --git a/x/auth/migrations/legacytx/stdtx.go b/x/auth/migrations/legacytx/stdtx.go index dc5dba098860..5e67518716d5 100644 --- a/x/auth/migrations/legacytx/stdtx.go +++ b/x/auth/migrations/legacytx/stdtx.go @@ -1,6 +1,8 @@ package legacytx import ( + gogoprotoany "github.com/cosmos/gogoproto/types/any" + errorsmod "cosmossdk.io/errors" "cosmossdk.io/math" @@ -13,9 +15,9 @@ import ( // Interface implementation checks var ( - _ codectypes.UnpackInterfacesMessage = (*StdTx)(nil) + _ gogoprotoany.UnpackInterfacesMessage = (*StdTx)(nil) - _ codectypes.UnpackInterfacesMessage = (*StdSignature)(nil) + _ gogoprotoany.UnpackInterfacesMessage = (*StdSignature)(nil) ) // StdFee includes the amount of coins paid in fees and the maximum @@ -169,7 +171,7 @@ func (tx StdTx) FeeGranter() sdk.AccAddress { return nil } -func (tx StdTx) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { +func (tx StdTx) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { for _, m := range tx.Msgs { err := codectypes.UnpackInterfaces(m, unpacker) if err != nil { diff --git a/x/auth/types/account.go b/x/auth/types/account.go index 263c5ee41ee1..ccdff269125f 100644 --- a/x/auth/types/account.go +++ b/x/auth/types/account.go @@ -7,6 +7,8 @@ import ( "fmt" "strings" + gogoprotoany "github.com/cosmos/gogoproto/types/any" + codectypes "github.com/cosmos/cosmos-sdk/codec/types" cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" sdk "github.com/cosmos/cosmos-sdk/types" @@ -14,11 +16,11 @@ import ( ) var ( - _ sdk.AccountI = (*BaseAccount)(nil) - _ GenesisAccount = (*BaseAccount)(nil) - _ codectypes.UnpackInterfacesMessage = (*BaseAccount)(nil) - _ GenesisAccount = (*ModuleAccount)(nil) - _ sdk.ModuleAccountI = (*ModuleAccount)(nil) + _ sdk.AccountI = (*BaseAccount)(nil) + _ GenesisAccount = (*BaseAccount)(nil) + _ gogoprotoany.UnpackInterfacesMessage = (*BaseAccount)(nil) + _ GenesisAccount = (*ModuleAccount)(nil) + _ sdk.ModuleAccountI = (*ModuleAccount)(nil) ) // NewBaseAccount creates a new BaseAccount object. @@ -132,7 +134,7 @@ func (acc BaseAccount) Validate() error { } // UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces -func (acc BaseAccount) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { +func (acc BaseAccount) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { if acc.PubKey == nil { return nil } diff --git a/x/auth/types/genesis.go b/x/auth/types/genesis.go index b31c686bc43f..d0b6db9dbefd 100644 --- a/x/auth/types/genesis.go +++ b/x/auth/types/genesis.go @@ -7,6 +7,7 @@ import ( "sort" "github.com/cosmos/gogoproto/proto" + gogoprotoany "github.com/cosmos/gogoproto/types/any" "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/codec/types" @@ -14,7 +15,7 @@ import ( "github.com/cosmos/cosmos-sdk/types/module" ) -var _ types.UnpackInterfacesMessage = GenesisState{} +var _ gogoprotoany.UnpackInterfacesMessage = GenesisState{} // RandomGenesisAccountsFn defines the function required to generate custom account types type RandomGenesisAccountsFn func(simState *module.SimulationState) GenesisAccounts @@ -32,7 +33,7 @@ func NewGenesisState(params Params, accounts GenesisAccounts) *GenesisState { } // UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces -func (g GenesisState) UnpackInterfaces(unpacker types.AnyUnpacker) error { +func (g GenesisState) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { for _, any := range g.Accounts { var account GenesisAccount err := unpacker.UnpackAny(any, &account) diff --git a/x/auth/types/query.go b/x/auth/types/query.go index 8ab9df38f9f0..96b089e18a74 100644 --- a/x/auth/types/query.go +++ b/x/auth/types/query.go @@ -1,13 +1,14 @@ package types import ( - codectypes "github.com/cosmos/cosmos-sdk/codec/types" + gogoprotoany "github.com/cosmos/gogoproto/types/any" + sdk "github.com/cosmos/cosmos-sdk/types" ) -func (m *QueryAccountResponse) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { +func (m *QueryAccountResponse) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { var account sdk.AccountI return unpacker.UnpackAny(m.Account, &account) } -var _ codectypes.UnpackInterfacesMessage = &QueryAccountResponse{} +var _ gogoprotoany.UnpackInterfacesMessage = &QueryAccountResponse{} diff --git a/x/authz/authorization_grant.go b/x/authz/authorization_grant.go index 9dd8aced3791..c054eb081403 100644 --- a/x/authz/authorization_grant.go +++ b/x/authz/authorization_grant.go @@ -4,10 +4,10 @@ import ( "time" "github.com/cosmos/gogoproto/proto" + gogoprotoany "github.com/cosmos/gogoproto/types/any" errorsmod "cosmossdk.io/errors" - cdctypes "github.com/cosmos/cosmos-sdk/codec/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" ) @@ -22,7 +22,7 @@ func NewGrant(blockTime time.Time, a Authorization, expiration *time.Time) (Gran if !ok { return Grant{}, sdkerrors.ErrPackAny.Wrapf("cannot proto marshal %T", a) } - any, err := cdctypes.NewAnyWithValue(msg) + any, err := gogoprotoany.NewAnyWithCacheWithValue(msg) if err != nil { return Grant{}, err } @@ -32,10 +32,10 @@ func NewGrant(blockTime time.Time, a Authorization, expiration *time.Time) (Gran }, nil } -var _ cdctypes.UnpackInterfacesMessage = &Grant{} +var _ gogoprotoany.UnpackInterfacesMessage = &Grant{} // UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces -func (g Grant) UnpackInterfaces(unpacker cdctypes.AnyUnpacker) error { +func (g Grant) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { var authorization Authorization return unpacker.UnpackAny(g.Authorization, &authorization) } diff --git a/x/authz/genesis.go b/x/authz/genesis.go index 2e7dde1b7260..f2afc47cad91 100644 --- a/x/authz/genesis.go +++ b/x/authz/genesis.go @@ -3,7 +3,7 @@ package authz import ( "fmt" - cdctypes "github.com/cosmos/cosmos-sdk/codec/types" + gogoprotoany "github.com/cosmos/gogoproto/types/any" ) // NewGenesisState creates new GenesisState object @@ -32,10 +32,10 @@ func DefaultGenesisState() *GenesisState { return &GenesisState{} } -var _ cdctypes.UnpackInterfacesMessage = GenesisState{} +var _ gogoprotoany.UnpackInterfacesMessage = GenesisState{} // UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces -func (data GenesisState) UnpackInterfaces(unpacker cdctypes.AnyUnpacker) error { +func (data GenesisState) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { for _, a := range data.Authorization { err := a.UnpackInterfaces(unpacker) if err != nil { @@ -46,7 +46,7 @@ func (data GenesisState) UnpackInterfaces(unpacker cdctypes.AnyUnpacker) error { } // UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces -func (msg GrantAuthorization) UnpackInterfaces(unpacker cdctypes.AnyUnpacker) error { +func (msg GrantAuthorization) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { var a Authorization return unpacker.UnpackAny(msg.Authorization, &a) } diff --git a/x/authz/msgs.go b/x/authz/msgs.go index 0964f45cb34b..b7c7c6c9cd30 100644 --- a/x/authz/msgs.go +++ b/x/authz/msgs.go @@ -4,6 +4,7 @@ import ( "time" "github.com/cosmos/gogoproto/proto" + gogoprotoany "github.com/cosmos/gogoproto/types/any" cdctypes "github.com/cosmos/cosmos-sdk/codec/types" sdk "github.com/cosmos/cosmos-sdk/types" @@ -15,8 +16,8 @@ var ( _ sdk.Msg = &MsgRevoke{} _ sdk.Msg = &MsgExec{} - _ cdctypes.UnpackInterfacesMessage = &MsgGrant{} - _ cdctypes.UnpackInterfacesMessage = &MsgExec{} + _ gogoprotoany.UnpackInterfacesMessage = &MsgGrant{} + _ gogoprotoany.UnpackInterfacesMessage = &MsgExec{} ) // NewMsgGrant creates a new MsgGrant @@ -44,7 +45,7 @@ func (msg *MsgGrant) SetAuthorization(a Authorization) error { if !ok { return sdkerrors.ErrPackAny.Wrapf("can't proto marshal %T", m) } - any, err := cdctypes.NewAnyWithValue(m) + any, err := gogoprotoany.NewAnyWithCacheWithValue(m) if err != nil { return err } @@ -53,7 +54,7 @@ func (msg *MsgGrant) SetAuthorization(a Authorization) error { } // UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces -func (msg MsgExec) UnpackInterfaces(unpacker cdctypes.AnyUnpacker) error { +func (msg MsgExec) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { for _, x := range msg.Msgs { var msgExecAuthorized sdk.Msg err := unpacker.UnpackAny(x, &msgExecAuthorized) @@ -66,7 +67,7 @@ func (msg MsgExec) UnpackInterfaces(unpacker cdctypes.AnyUnpacker) error { } // UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces -func (msg MsgGrant) UnpackInterfaces(unpacker cdctypes.AnyUnpacker) error { +func (msg MsgGrant) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { return msg.Grant.UnpackInterfaces(unpacker) } diff --git a/x/authz/simulation/operations.go b/x/authz/simulation/operations.go index ec62f5196b2f..374a451cfc23 100644 --- a/x/authz/simulation/operations.go +++ b/x/authz/simulation/operations.go @@ -5,6 +5,8 @@ import ( "math/rand" "time" + gogoprotoany "github.com/cosmos/gogoproto/types/any" + "cosmossdk.io/core/address" "cosmossdk.io/core/appmodule" corecontext "cosmossdk.io/core/context" @@ -260,7 +262,7 @@ func SimulateMsgExec( ak authz.AccountKeeper, bk authz.BankKeeper, k keeper.Keeper, - unpacker cdctypes.AnyUnpacker, + unpacker gogoprotoany.AnyUnpacker, ) simtypes.Operation { return func( r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accs []simtypes.Account, chainID string, diff --git a/x/evidence/types/genesis.go b/x/evidence/types/genesis.go index d9ccaefbe729..e5c683831663 100644 --- a/x/evidence/types/genesis.go +++ b/x/evidence/types/genesis.go @@ -4,13 +4,14 @@ import ( "fmt" "github.com/cosmos/gogoproto/proto" + gogoprotoany "github.com/cosmos/gogoproto/types/any" "cosmossdk.io/x/evidence/exported" "github.com/cosmos/cosmos-sdk/codec/types" ) -var _ types.UnpackInterfacesMessage = GenesisState{} +var _ gogoprotoany.UnpackInterfacesMessage = GenesisState{} // NewGenesisState creates a new genesis state for the evidence module. func NewGenesisState(e []exported.Evidence) *GenesisState { @@ -55,7 +56,7 @@ func (gs GenesisState) Validate() error { } // UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces -func (gs GenesisState) UnpackInterfaces(unpacker types.AnyUnpacker) error { +func (gs GenesisState) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { for _, any := range gs.Evidence { var evi exported.Evidence err := unpacker.UnpackAny(any, &evi) diff --git a/x/evidence/types/genesis_test.go b/x/evidence/types/genesis_test.go index 20b5967ac2eb..786b2103f762 100644 --- a/x/evidence/types/genesis_test.go +++ b/x/evidence/types/genesis_test.go @@ -5,6 +5,7 @@ import ( "testing" "time" + gogoprotoany "github.com/cosmos/gogoproto/types/any" "github.com/stretchr/testify/require" "cosmossdk.io/x/evidence/exported" @@ -130,7 +131,7 @@ func TestUnpackInterfaces(t *testing.T) { testCases := []struct { msg string - unpacker codectypes.AnyUnpacker + unpacker gogoprotoany.AnyUnpacker expPass bool }{ { diff --git a/x/evidence/types/msgs.go b/x/evidence/types/msgs.go index 92df414692a5..03e70b5ab7df 100644 --- a/x/evidence/types/msgs.go +++ b/x/evidence/types/msgs.go @@ -4,6 +4,7 @@ import ( "fmt" "github.com/cosmos/gogoproto/proto" + gogoprotoany "github.com/cosmos/gogoproto/types/any" "cosmossdk.io/x/evidence/exported" @@ -12,9 +13,9 @@ import ( ) var ( - _ sdk.Msg = &MsgSubmitEvidence{} - _ types.UnpackInterfacesMessage = MsgSubmitEvidence{} - _ exported.MsgSubmitEvidenceI = &MsgSubmitEvidence{} + _ sdk.Msg = &MsgSubmitEvidence{} + _ gogoprotoany.UnpackInterfacesMessage = MsgSubmitEvidence{} + _ exported.MsgSubmitEvidenceI = &MsgSubmitEvidence{} ) // NewMsgSubmitEvidence returns a new MsgSubmitEvidence with a signer/submitter. @@ -51,7 +52,7 @@ func (m MsgSubmitEvidence) GetSubmitter() sdk.AccAddress { return accAddr } -func (m MsgSubmitEvidence) UnpackInterfaces(ctx types.AnyUnpacker) error { +func (m MsgSubmitEvidence) UnpackInterfaces(ctx gogoprotoany.AnyUnpacker) error { var evi exported.Evidence return ctx.UnpackAny(m.Evidence, &evi) } diff --git a/x/feegrant/filtered_fee.go b/x/feegrant/filtered_fee.go index 6e001ef947e9..a6c0d537a3f6 100644 --- a/x/feegrant/filtered_fee.go +++ b/x/feegrant/filtered_fee.go @@ -6,6 +6,7 @@ import ( "time" "github.com/cosmos/gogoproto/proto" + gogoprotoany "github.com/cosmos/gogoproto/types/any" "cosmossdk.io/core/appmodule" corecontext "cosmossdk.io/core/context" @@ -23,12 +24,12 @@ const ( ) var ( - _ FeeAllowanceI = (*AllowedMsgAllowance)(nil) - _ types.UnpackInterfacesMessage = (*AllowedMsgAllowance)(nil) + _ FeeAllowanceI = (*AllowedMsgAllowance)(nil) + _ gogoprotoany.UnpackInterfacesMessage = (*AllowedMsgAllowance)(nil) ) // UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces -func (a *AllowedMsgAllowance) UnpackInterfaces(unpacker types.AnyUnpacker) error { +func (a *AllowedMsgAllowance) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { var allowance FeeAllowanceI return unpacker.UnpackAny(a.Allowance, &allowance) } diff --git a/x/feegrant/genesis.go b/x/feegrant/genesis.go index 83b29baeb85d..71ddf943a3e3 100644 --- a/x/feegrant/genesis.go +++ b/x/feegrant/genesis.go @@ -1,10 +1,10 @@ package feegrant import ( - "github.com/cosmos/cosmos-sdk/codec/types" + gogoprotoany "github.com/cosmos/gogoproto/types/any" ) -var _ types.UnpackInterfacesMessage = GenesisState{} +var _ gogoprotoany.UnpackInterfacesMessage = GenesisState{} // NewGenesisState creates new GenesisState object func NewGenesisState(entries []Grant) *GenesisState { @@ -34,7 +34,7 @@ func DefaultGenesisState() *GenesisState { } // UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces -func (data GenesisState) UnpackInterfaces(unpacker types.AnyUnpacker) error { +func (data GenesisState) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { for _, f := range data.Allowances { err := f.UnpackInterfaces(unpacker) if err != nil { diff --git a/x/feegrant/grant.go b/x/feegrant/grant.go index 0fb85dd5a226..a483475c6b41 100644 --- a/x/feegrant/grant.go +++ b/x/feegrant/grant.go @@ -2,6 +2,7 @@ package feegrant import ( "github.com/cosmos/gogoproto/proto" + gogoprotoany "github.com/cosmos/gogoproto/types/any" errorsmod "cosmossdk.io/errors" @@ -9,7 +10,7 @@ import ( sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" ) -var _ types.UnpackInterfacesMessage = &Grant{} +var _ gogoprotoany.UnpackInterfacesMessage = &Grant{} // NewGrant creates a new FeeAllowanceGrant. func NewGrant(granter, grantee string, feeAllowance FeeAllowanceI) (Grant, error) { @@ -62,7 +63,7 @@ func (a Grant) GetGrant() (FeeAllowanceI, error) { } // UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces -func (a Grant) UnpackInterfaces(unpacker types.AnyUnpacker) error { +func (a Grant) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { var allowance FeeAllowanceI return unpacker.UnpackAny(a.Allowance, &allowance) } diff --git a/x/feegrant/msgs.go b/x/feegrant/msgs.go index c049c73d4f3f..e79c5ce39ab9 100644 --- a/x/feegrant/msgs.go +++ b/x/feegrant/msgs.go @@ -2,6 +2,7 @@ package feegrant import ( "github.com/cosmos/gogoproto/proto" + gogoprotoany "github.com/cosmos/gogoproto/types/any" errorsmod "cosmossdk.io/errors" @@ -11,8 +12,8 @@ import ( ) var ( - _, _ sdk.Msg = &MsgGrantAllowance{}, &MsgRevokeAllowance{} - _ types.UnpackInterfacesMessage = &MsgGrantAllowance{} + _, _ sdk.Msg = &MsgGrantAllowance{}, &MsgRevokeAllowance{} + _ gogoprotoany.UnpackInterfacesMessage = &MsgGrantAllowance{} ) // NewMsgGrantAllowance creates a new MsgGrantAllowance. @@ -44,7 +45,7 @@ func (msg MsgGrantAllowance) GetFeeAllowanceI() (FeeAllowanceI, error) { } // UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces -func (msg MsgGrantAllowance) UnpackInterfaces(unpacker types.AnyUnpacker) error { +func (msg MsgGrantAllowance) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { var allowance FeeAllowanceI return unpacker.UnpackAny(msg.Allowance, &allowance) } diff --git a/x/gov/types/v1/genesis.go b/x/gov/types/v1/genesis.go index 21721e4b024e..e4a8ae280509 100644 --- a/x/gov/types/v1/genesis.go +++ b/x/gov/types/v1/genesis.go @@ -4,11 +4,10 @@ import ( "errors" "fmt" + gogoprotoany "github.com/cosmos/gogoproto/types/any" "golang.org/x/sync/errgroup" "cosmossdk.io/core/address" - - "github.com/cosmos/cosmos-sdk/codec/types" ) // NewGenesisState creates a new genesis state for the governance module @@ -107,10 +106,10 @@ func ValidateGenesis(ac address.Codec, data *GenesisState) error { return errGroup.Wait() } -var _ types.UnpackInterfacesMessage = GenesisState{} +var _ gogoprotoany.UnpackInterfacesMessage = GenesisState{} // UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces -func (data GenesisState) UnpackInterfaces(unpacker types.AnyUnpacker) error { +func (data GenesisState) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { for _, p := range data.Proposals { err := p.UnpackInterfaces(unpacker) if err != nil { diff --git a/x/gov/types/v1/msgs.go b/x/gov/types/v1/msgs.go index d25a9ed33aad..70b4b90c5c73 100644 --- a/x/gov/types/v1/msgs.go +++ b/x/gov/types/v1/msgs.go @@ -4,6 +4,8 @@ import ( "errors" "fmt" + gogoprotoany "github.com/cosmos/gogoproto/types/any" + "cosmossdk.io/x/gov/types/v1beta1" codectypes "github.com/cosmos/cosmos-sdk/codec/types" @@ -12,8 +14,8 @@ import ( ) var ( - _, _, _, _, _, _, _, _ sdk.Msg = &MsgSubmitProposal{}, &MsgDeposit{}, &MsgVote{}, &MsgVoteWeighted{}, &MsgExecLegacyContent{}, &MsgUpdateParams{}, &MsgCancelProposal{}, &MsgSubmitMultipleChoiceProposal{} - _, _ codectypes.UnpackInterfacesMessage = &MsgSubmitProposal{}, &MsgExecLegacyContent{} + _, _, _, _, _, _, _, _ sdk.Msg = &MsgSubmitProposal{}, &MsgDeposit{}, &MsgVote{}, &MsgVoteWeighted{}, &MsgExecLegacyContent{}, &MsgUpdateParams{}, &MsgCancelProposal{}, &MsgSubmitMultipleChoiceProposal{} + _, _ gogoprotoany.UnpackInterfacesMessage = &MsgSubmitProposal{}, &MsgExecLegacyContent{} ) // NewMsgSubmitProposal creates a new MsgSubmitProposal. @@ -60,7 +62,7 @@ func (m *MsgSubmitProposal) SetMsgs(msgs []sdk.Msg) error { } // UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces -func (m MsgSubmitProposal) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { +func (m MsgSubmitProposal) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { return sdktx.UnpackInterfaces(unpacker, m.Messages) } @@ -120,7 +122,7 @@ func (c MsgExecLegacyContent) ValidateBasic() error { } // UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces -func (c MsgExecLegacyContent) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { +func (c MsgExecLegacyContent) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { var content v1beta1.Content return unpacker.UnpackAny(c.Content, &content) } diff --git a/x/gov/types/v1/proposal.go b/x/gov/types/v1/proposal.go index be5931c217ae..e9a901934c58 100644 --- a/x/gov/types/v1/proposal.go +++ b/x/gov/types/v1/proposal.go @@ -5,7 +5,8 @@ import ( "strings" "time" - codectypes "github.com/cosmos/cosmos-sdk/codec/types" + gogoprotoany "github.com/cosmos/gogoproto/types/any" + sdk "github.com/cosmos/cosmos-sdk/types" sdktx "github.com/cosmos/cosmos-sdk/types/tx" ) @@ -74,14 +75,14 @@ func (p Proposal) GetMinDepositFromParams(params Params) sdk.Coins { } // UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces -func (p Proposal) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { +func (p Proposal) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { return sdktx.UnpackInterfaces(unpacker, p.Messages) } // Proposals is an array of proposal type Proposals []*Proposal -var _ codectypes.UnpackInterfacesMessage = Proposals{} +var _ gogoprotoany.UnpackInterfacesMessage = Proposals{} // String implements stringer interface func (p Proposals) String() string { @@ -94,7 +95,7 @@ func (p Proposals) String() string { } // UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces -func (p Proposals) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { +func (p Proposals) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { for _, x := range p { err := x.UnpackInterfaces(unpacker) if err != nil { diff --git a/x/gov/types/v1beta1/genesis.go b/x/gov/types/v1beta1/genesis.go index d71c008d8860..d2c288574db6 100644 --- a/x/gov/types/v1beta1/genesis.go +++ b/x/gov/types/v1beta1/genesis.go @@ -3,9 +3,9 @@ package v1beta1 import ( "fmt" - "cosmossdk.io/math" + gogoprotoany "github.com/cosmos/gogoproto/types/any" - "github.com/cosmos/cosmos-sdk/codec/types" + "cosmossdk.io/math" ) // NewGenesisState creates a new genesis state for the governance module @@ -66,10 +66,10 @@ func ValidateGenesis(data *GenesisState) error { return nil } -var _ types.UnpackInterfacesMessage = GenesisState{} +var _ gogoprotoany.UnpackInterfacesMessage = GenesisState{} // UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces -func (data GenesisState) UnpackInterfaces(unpacker types.AnyUnpacker) error { +func (data GenesisState) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { for _, p := range data.Proposals { err := p.UnpackInterfaces(unpacker) if err != nil { diff --git a/x/gov/types/v1beta1/msgs.go b/x/gov/types/v1beta1/msgs.go index 298f26c592eb..984bed150093 100644 --- a/x/gov/types/v1beta1/msgs.go +++ b/x/gov/types/v1beta1/msgs.go @@ -4,6 +4,7 @@ import ( "fmt" "github.com/cosmos/gogoproto/proto" + gogoprotoany "github.com/cosmos/gogoproto/types/any" codectypes "github.com/cosmos/cosmos-sdk/codec/types" sdk "github.com/cosmos/cosmos-sdk/types" @@ -20,7 +21,7 @@ const ( var ( _, _, _, _ sdk.Msg = &MsgSubmitProposal{}, &MsgDeposit{}, &MsgVote{}, &MsgVoteWeighted{} - _ codectypes.UnpackInterfacesMessage = &MsgSubmitProposal{} + _ gogoprotoany.UnpackInterfacesMessage = &MsgSubmitProposal{} ) // NewMsgSubmitProposal creates a new MsgSubmitProposal. @@ -73,7 +74,7 @@ func (m *MsgSubmitProposal) SetContent(content Content) error { } // UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces -func (m MsgSubmitProposal) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { +func (m MsgSubmitProposal) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { var content Content return unpacker.UnpackAny(m.Content, &content) } diff --git a/x/gov/types/v1beta1/proposal.go b/x/gov/types/v1beta1/proposal.go index b29753edb33b..814301406861 100644 --- a/x/gov/types/v1beta1/proposal.go +++ b/x/gov/types/v1beta1/proposal.go @@ -7,6 +7,7 @@ import ( "time" "github.com/cosmos/gogoproto/proto" + gogoprotoany "github.com/cosmos/gogoproto/types/any" errorsmod "cosmossdk.io/errors" "cosmossdk.io/x/gov/types" @@ -81,7 +82,7 @@ func (p Proposal) GetTitle() string { } // UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces -func (p Proposal) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { +func (p Proposal) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { var content Content return unpacker.UnpackAny(p.Content, &content) } @@ -89,7 +90,7 @@ func (p Proposal) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { // Proposals is an array of proposal type Proposals []Proposal -var _ codectypes.UnpackInterfacesMessage = Proposals{} +var _ gogoprotoany.UnpackInterfacesMessage = Proposals{} // Equal returns true if two slices (order-dependant) of proposals are equal. func (p Proposals) Equal(other Proposals) bool { @@ -118,7 +119,7 @@ func (p Proposals) String() string { } // UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces -func (p Proposals) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { +func (p Proposals) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { for _, x := range p { err := x.UnpackInterfaces(unpacker) if err != nil { diff --git a/x/group/genesis.go b/x/group/genesis.go index eccf1f941e05..2a7e073890ba 100644 --- a/x/group/genesis.go +++ b/x/group/genesis.go @@ -3,9 +3,10 @@ package group import ( "fmt" + gogoprotoany "github.com/cosmos/gogoproto/types/any" + errorsmod "cosmossdk.io/errors" - "github.com/cosmos/cosmos-sdk/codec/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" ) @@ -83,7 +84,7 @@ func (s GenesisState) Validate() error { } // UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces -func (s GenesisState) UnpackInterfaces(unpacker types.AnyUnpacker) error { +func (s GenesisState) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { for _, g := range s.GroupPolicies { err := g.UnpackInterfaces(unpacker) if err != nil { diff --git a/x/group/msgs.go b/x/group/msgs.go index d9aad25d63b3..a9e36c207f48 100644 --- a/x/group/msgs.go +++ b/x/group/msgs.go @@ -2,6 +2,7 @@ package group import ( "github.com/cosmos/gogoproto/proto" + gogoprotoany "github.com/cosmos/gogoproto/types/any" "github.com/cosmos/cosmos-sdk/codec/types" sdk "github.com/cosmos/cosmos-sdk/types" @@ -27,9 +28,9 @@ var ( _ sdk.Msg = &MsgSubmitProposal{} _ sdk.Msg = &MsgCreateGroupPolicy{} - _ types.UnpackInterfacesMessage = MsgCreateGroupPolicy{} - _ types.UnpackInterfacesMessage = MsgUpdateGroupPolicyDecisionPolicy{} - _ types.UnpackInterfacesMessage = MsgCreateGroupWithPolicy{} + _ gogoprotoany.UnpackInterfacesMessage = MsgCreateGroupPolicy{} + _ gogoprotoany.UnpackInterfacesMessage = MsgUpdateGroupPolicyDecisionPolicy{} + _ gogoprotoany.UnpackInterfacesMessage = MsgCreateGroupWithPolicy{} ) // GetGroupID gets the group id of the MsgUpdateGroupMetadata. @@ -83,7 +84,7 @@ func (m *MsgCreateGroupWithPolicy) SetDecisionPolicy(decisionPolicy DecisionPoli } // UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces -func (m MsgCreateGroupWithPolicy) UnpackInterfaces(unpacker types.AnyUnpacker) error { +func (m MsgCreateGroupWithPolicy) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { var decisionPolicy DecisionPolicy return unpacker.UnpackAny(m.DecisionPolicy, &decisionPolicy) } @@ -126,7 +127,7 @@ func (m *MsgUpdateGroupPolicyDecisionPolicy) GetDecisionPolicy() (DecisionPolicy } // UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces -func (m MsgUpdateGroupPolicyDecisionPolicy) UnpackInterfaces(unpacker types.AnyUnpacker) error { +func (m MsgUpdateGroupPolicyDecisionPolicy) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { var decisionPolicy DecisionPolicy return unpacker.UnpackAny(m.DecisionPolicy, &decisionPolicy) } @@ -180,7 +181,7 @@ func (m *MsgCreateGroupPolicy) SetDecisionPolicy(decisionPolicy DecisionPolicy) } // UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces -func (m MsgCreateGroupPolicy) UnpackInterfaces(unpacker types.AnyUnpacker) error { +func (m MsgCreateGroupPolicy) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { var decisionPolicy DecisionPolicy return unpacker.UnpackAny(m.DecisionPolicy, &decisionPolicy) } @@ -218,6 +219,6 @@ func (m MsgSubmitProposal) GetMsgs() ([]sdk.Msg, error) { } // UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces -func (m MsgSubmitProposal) UnpackInterfaces(unpacker types.AnyUnpacker) error { +func (m MsgSubmitProposal) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { return tx.UnpackInterfaces(unpacker, m.Messages) } diff --git a/x/group/proposal.go b/x/group/proposal.go index a47ee5115c3b..642e8981a487 100644 --- a/x/group/proposal.go +++ b/x/group/proposal.go @@ -1,7 +1,8 @@ package group import ( - "github.com/cosmos/cosmos-sdk/codec/types" + gogoprotoany "github.com/cosmos/gogoproto/types/any" + sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/tx" ) @@ -22,6 +23,6 @@ func (p *Proposal) SetMsgs(msgs []sdk.Msg) error { } // UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces -func (p Proposal) UnpackInterfaces(unpacker types.AnyUnpacker) error { +func (p Proposal) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { return tx.UnpackInterfaces(unpacker, p.Messages) } diff --git a/x/group/simulation/operations.go b/x/group/simulation/operations.go index 2a90842681dc..d0eb1b8f7989 100644 --- a/x/group/simulation/operations.go +++ b/x/group/simulation/operations.go @@ -8,6 +8,8 @@ import ( "sync/atomic" "time" + gogoprotoany "github.com/cosmos/gogoproto/types/any" + "cosmossdk.io/core/address" "cosmossdk.io/x/group" "cosmossdk.io/x/group/keeper" @@ -104,7 +106,7 @@ func WeightedOperations( registry cdctypes.InterfaceRegistry, appParams simtypes.AppParams, cdc codec.JSONCodec, txGen client.TxConfig, ak group.AccountKeeper, bk group.BankKeeper, k keeper.Keeper, - appCdc cdctypes.AnyUnpacker, + appCdc gogoprotoany.AnyUnpacker, ) simulation.WeightedOperations { var ( weightMsgCreateGroup int diff --git a/x/group/types.go b/x/group/types.go index 4a8b2cd7d564..d91d4fd89704 100644 --- a/x/group/types.go +++ b/x/group/types.go @@ -5,6 +5,7 @@ import ( "time" "github.com/cosmos/gogoproto/proto" + gogoprotoany "github.com/cosmos/gogoproto/types/any" "cosmossdk.io/core/address" errorsmod "cosmossdk.io/errors" @@ -286,7 +287,7 @@ func (g GroupPolicyInfo) GetDecisionPolicy() (DecisionPolicy, error) { } // UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces -func (g GroupPolicyInfo) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { +func (g GroupPolicyInfo) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { var decisionPolicy DecisionPolicy return unpacker.UnpackAny(g.DecisionPolicy, &decisionPolicy) } @@ -458,16 +459,16 @@ func (v Vote) ValidateBasic() error { } // UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces -func (q QueryGroupPoliciesByGroupResponse) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { +func (q QueryGroupPoliciesByGroupResponse) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { return unpackGroupPolicies(unpacker, q.GroupPolicies) } // UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces -func (q QueryGroupPoliciesByAdminResponse) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { +func (q QueryGroupPoliciesByAdminResponse) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { return unpackGroupPolicies(unpacker, q.GroupPolicies) } -func unpackGroupPolicies(unpacker codectypes.AnyUnpacker, accs []*GroupPolicyInfo) error { +func unpackGroupPolicies(unpacker gogoprotoany.AnyUnpacker, accs []*GroupPolicyInfo) error { for _, g := range accs { err := g.UnpackInterfaces(unpacker) if err != nil { diff --git a/x/staking/types/genesis.go b/x/staking/types/genesis.go index e144661afe55..e3534fc4ea58 100644 --- a/x/staking/types/genesis.go +++ b/x/staking/types/genesis.go @@ -3,8 +3,9 @@ package types import ( "encoding/json" + gogoprotoany "github.com/cosmos/gogoproto/types/any" + "github.com/cosmos/cosmos-sdk/codec" - codectypes "github.com/cosmos/cosmos-sdk/codec/types" ) // NewGenesisState creates a new GenesisState instance @@ -36,7 +37,7 @@ func GetGenesisStateFromAppState(cdc codec.JSONCodec, appState map[string]json.R } // UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces -func (g GenesisState) UnpackInterfaces(c codectypes.AnyUnpacker) error { +func (g GenesisState) UnpackInterfaces(c gogoprotoany.AnyUnpacker) error { for i := range g.Validators { if err := g.Validators[i].UnpackInterfaces(c); err != nil { return err diff --git a/x/staking/types/msg.go b/x/staking/types/msg.go index 3effad961f14..782183ff0684 100644 --- a/x/staking/types/msg.go +++ b/x/staking/types/msg.go @@ -1,6 +1,8 @@ package types import ( + gogoprotoany "github.com/cosmos/gogoproto/types/any" + "cosmossdk.io/core/address" coretransaction "cosmossdk.io/core/transaction" errorsmod "cosmossdk.io/errors" @@ -13,14 +15,14 @@ import ( ) var ( - _ coretransaction.Msg = &MsgCreateValidator{} - _ codectypes.UnpackInterfacesMessage = (*MsgCreateValidator)(nil) - _ coretransaction.Msg = &MsgEditValidator{} - _ coretransaction.Msg = &MsgDelegate{} - _ coretransaction.Msg = &MsgUndelegate{} - _ coretransaction.Msg = &MsgBeginRedelegate{} - _ coretransaction.Msg = &MsgCancelUnbondingDelegation{} - _ coretransaction.Msg = &MsgUpdateParams{} + _ coretransaction.Msg = &MsgCreateValidator{} + _ gogoprotoany.UnpackInterfacesMessage = (*MsgCreateValidator)(nil) + _ coretransaction.Msg = &MsgEditValidator{} + _ coretransaction.Msg = &MsgDelegate{} + _ coretransaction.Msg = &MsgUndelegate{} + _ coretransaction.Msg = &MsgBeginRedelegate{} + _ coretransaction.Msg = &MsgCancelUnbondingDelegation{} + _ coretransaction.Msg = &MsgUpdateParams{} ) // NewMsgCreateValidator creates a new MsgCreateValidator instance. @@ -89,7 +91,7 @@ func (msg MsgCreateValidator) Validate(ac address.Codec) error { } // UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces -func (msg MsgCreateValidator) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { +func (msg MsgCreateValidator) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { var pubKey cryptotypes.PubKey return unpacker.UnpackAny(msg.Pubkey, &pubKey) } @@ -160,13 +162,13 @@ func NewMsgRotateConsPubKey(valAddr string, pubKey cryptotypes.PubKey) (*MsgRota } // UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces -func (msg MsgRotateConsPubKey) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { +func (msg MsgRotateConsPubKey) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { var pubKey cryptotypes.PubKey return unpacker.UnpackAny(msg.NewPubkey, &pubKey) } // UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces -func (hi ConsPubKeyRotationHistory) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { +func (hi ConsPubKeyRotationHistory) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { var oldPubKey cryptotypes.PubKey err := unpacker.UnpackAny(hi.OldConsPubkey, &oldPubKey) if err != nil { diff --git a/x/staking/types/validator.go b/x/staking/types/validator.go index 9906bc2b8009..c2e442d4c55a 100644 --- a/x/staking/types/validator.go +++ b/x/staking/types/validator.go @@ -7,6 +7,8 @@ import ( "strings" "time" + gogoprotoany "github.com/cosmos/gogoproto/types/any" + "cosmossdk.io/core/address" "cosmossdk.io/core/appmodule" "cosmossdk.io/errors" @@ -138,7 +140,7 @@ func (valz ValidatorsByVotingPower) Swap(i, j int) { } // UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces -func (v Validators) UnpackInterfaces(c codectypes.AnyUnpacker) error { +func (v Validators) UnpackInterfaces(c gogoprotoany.AnyUnpacker) error { for i := range v.Validators { if err := v.Validators[i].UnpackInterfaces(c); err != nil { return err @@ -494,7 +496,7 @@ func (v Validator) GetMinSelfDelegation() math.Int { return v.MinSelfDelegat func (v Validator) GetDelegatorShares() math.LegacyDec { return v.DelegatorShares } // UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces -func (v Validator) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { +func (v Validator) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { var pk cryptotypes.PubKey return unpacker.UnpackAny(v.ConsensusPubkey, &pk) } From ba7e6be7e9d829f9f508cc48e29c083dd6c8addf Mon Sep 17 00:00:00 2001 From: Cosmos SDK <113218068+github-prbot@users.noreply.github.com> Date: Mon, 22 Jul 2024 14:34:31 +0200 Subject: [PATCH 24/50] ci: skip spelling check in go.mod/go.sum (#21021) Co-authored-by: github-merge-queue <118344674+github-merge-queue@users.noreply.github.com> Co-authored-by: Julien Robert --- .github/workflows/misspell.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/misspell.yml b/.github/workflows/misspell.yml index f524e88b2cb8..e4cff28364c1 100644 --- a/.github/workflows/misspell.yml +++ b/.github/workflows/misspell.yml @@ -15,7 +15,7 @@ jobs: continue-on-error: true run: | sudo apt-get install codespell -y - codespell -w --skip="*.pulsar.go,*.pb.go,*.pb.gw.go,*.cosmos_orm.go,*.json,*.git,*.js,crypto/keys,fuzz,*.h,proto/tendermint,*.bin" --ignore-words=.github/.codespellignore + codespell -w --skip="*.pulsar.go,*.pb.go,*.pb.gw.go,*.cosmos_orm.go,*.json,*.git,*.js,crypto/keys,fuzz,*.h,proto/tendermint,*.bin,go.sum,go.mod" --ignore-words=.github/.codespellignore - uses: peter-evans/create-pull-request@v6 if: github.event_name != 'pull_request' with: From c2df06c98545d761a7c59aa1f2d859e264dcd852 Mon Sep 17 00:00:00 2001 From: Halimao <1065621723@qq.com> Date: Tue, 23 Jul 2024 02:01:07 +0800 Subject: [PATCH 25/50] chore: fix errors reported by running `make lint` (#21015) --- indexer/postgres/tests/init_schema_test.go | 4 +--- schema/decoding/decoding_test.go | 6 ++++-- schema/decoding/resolver_test.go | 1 - schema/decoding/sync.go | 1 - .../defaults/lockup/continuous_locking_account_test.go | 2 +- 5 files changed, 6 insertions(+), 8 deletions(-) diff --git a/indexer/postgres/tests/init_schema_test.go b/indexer/postgres/tests/init_schema_test.go index 1afa6caea9b4..8c4288ba344f 100644 --- a/indexer/postgres/tests/init_schema_test.go +++ b/indexer/postgres/tests/init_schema_test.go @@ -9,9 +9,7 @@ import ( embeddedpostgres "github.com/fergusstrange/embedded-postgres" "github.com/hashicorp/consul/sdk/freeport" - - // this is where we get our pgx database driver from - _ "github.com/jackc/pgx/v5/stdlib" + _ "github.com/jackc/pgx/v5/stdlib" // this is where we get our pgx database driver from "github.com/stretchr/testify/require" "gotest.tools/v3/golden" diff --git a/schema/decoding/decoding_test.go b/schema/decoding/decoding_test.go index 988c1b5ea2e4..d4308390d29c 100644 --- a/schema/decoding/decoding_test.go +++ b/schema/decoding/decoding_test.go @@ -68,7 +68,7 @@ func TestMiddleware_filtered(t *testing.T) { tl := newTestFixture(t) listener, err := Middleware(tl.Listener, tl.resolver, MiddlewareOptions{ ModuleFilter: func(moduleName string) bool { - return moduleName == "one" + return moduleName == "one" //nolint:goconst // adding constants for this would impede readability }, }) if err != nil { @@ -176,6 +176,7 @@ type testFixture struct { } func newTestFixture(t *testing.T) *testFixture { + t.Helper() res := &testFixture{} res.Listener = appdata.Listener{ InitializeModuleData: func(data appdata.ModuleInitializationData) error { @@ -246,7 +247,7 @@ func newTestMultiStore() *testMultiStore { var _ SyncSource = &testMultiStore{} -func (ms *testMultiStore) IterateAllKVPairs(moduleName string, fn func(key []byte, value []byte) error) error { +func (ms *testMultiStore) IterateAllKVPairs(moduleName string, fn func(key, value []byte) error) error { s, ok := ms.stores[moduleName] if !ok { return fmt.Errorf("don't have state for module %s", moduleName) @@ -267,6 +268,7 @@ func (ms *testMultiStore) IterateAllKVPairs(moduleName string, fn func(key []byt } func (ms *testMultiStore) newTestStore(t *testing.T, modName string) *testStore { + t.Helper() s := &testStore{ t: t, modName: modName, diff --git a/schema/decoding/resolver_test.go b/schema/decoding/resolver_test.go index d91197ac2675..f5caf287ca5f 100644 --- a/schema/decoding/resolver_test.go +++ b/schema/decoding/resolver_test.go @@ -39,7 +39,6 @@ func TestModuleSetDecoderResolver_IterateAll(t *testing.T) { objectTypes[cdc.Schema.ObjectTypes[0].Name] = true return nil }) - if err != nil { t.Fatalf("unexpected error: %v", err) } diff --git a/schema/decoding/sync.go b/schema/decoding/sync.go index 19582cfa37ad..d8aee9884c6a 100644 --- a/schema/decoding/sync.go +++ b/schema/decoding/sync.go @@ -8,7 +8,6 @@ import ( // SyncSource is an interface that allows indexers to start indexing modules with pre-existing state. // It should generally be a wrapper around the key-value store. type SyncSource interface { - // IterateAllKVPairs iterates over all key-value pairs for a given module. IterateAllKVPairs(moduleName string, fn func(key, value []byte) error) error } diff --git a/x/accounts/defaults/lockup/continuous_locking_account_test.go b/x/accounts/defaults/lockup/continuous_locking_account_test.go index dd208b26be74..cbccbb224ec5 100644 --- a/x/accounts/defaults/lockup/continuous_locking_account_test.go +++ b/x/accounts/defaults/lockup/continuous_locking_account_test.go @@ -19,7 +19,7 @@ import ( func setupContinousAccount(t *testing.T, ctx context.Context, ss store.KVStoreService) *ContinuousLockingAccount { t.Helper() deps := makeMockDependencies(ss) - owner := "owner" + owner := "owner" //nolint:goconst // adding constants for this would impede readability acc, err := NewContinuousLockingAccount(deps) require.NoError(t, err) From 67b5a5d268b5867633695746f1e17612b9027f0c Mon Sep 17 00:00:00 2001 From: yukionfire Date: Tue, 23 Jul 2024 16:10:09 +0800 Subject: [PATCH 26/50] chore(x): replace `fmt.Errorf` without parameters with `errors.New` (#21032) --- x/bank/client/cli/tx.go | 3 +- x/distribution/keeper/delegation.go | 6 ++-- x/distribution/types/params.go | 3 +- x/evidence/types/genesis.go | 3 +- x/feegrant/basic_fee.go | 4 +-- x/feegrant/filtered_fee.go | 6 ++-- x/genutil/client/cli/export_test.go | 6 ++-- x/genutil/utils.go | 5 ++-- x/gov/client/cli/util.go | 7 +++-- x/gov/keeper/common_test.go | 3 +- x/group/client/cli/util.go | 3 +- x/group/internal/math/dec.go | 18 ++++++------ x/group/internal/orm/iterator.go | 44 ++++++++++++++--------------- x/group/keeper/msg_server_test.go | 10 +++---- 14 files changed, 64 insertions(+), 57 deletions(-) diff --git a/x/bank/client/cli/tx.go b/x/bank/client/cli/tx.go index a480d3b1a2cc..1e86b92f7564 100644 --- a/x/bank/client/cli/tx.go +++ b/x/bank/client/cli/tx.go @@ -1,6 +1,7 @@ package cli import ( + "errors" "fmt" "github.com/spf13/cobra" @@ -64,7 +65,7 @@ When using '--dry-run' a key name cannot be used, only a bech32 address.`, } if coins.IsZero() { - return fmt.Errorf("must send positive amount") + return errors.New("must send positive amount") } split, err := cmd.Flags().GetBool(FlagSplit) diff --git a/x/distribution/keeper/delegation.go b/x/distribution/keeper/delegation.go index e175d48795b6..7bf2091edb89 100644 --- a/x/distribution/keeper/delegation.go +++ b/x/distribution/keeper/delegation.go @@ -52,12 +52,12 @@ func (k Keeper) calculateDelegationRewardsBetween(ctx context.Context, val sdk.V ) (sdk.DecCoins, error) { // sanity check if startingPeriod > endingPeriod { - return sdk.DecCoins{}, fmt.Errorf("startingPeriod cannot be greater than endingPeriod") + return sdk.DecCoins{}, errors.New("startingPeriod cannot be greater than endingPeriod") } // sanity check if stake.IsNegative() { - return sdk.DecCoins{}, fmt.Errorf("stake should not be negative") + return sdk.DecCoins{}, errors.New("stake should not be negative") } valBz, err := k.stakingKeeper.ValidatorAddressCodec().StringToBytes(val.GetOperator()) @@ -78,7 +78,7 @@ func (k Keeper) calculateDelegationRewardsBetween(ctx context.Context, val sdk.V difference := ending.CumulativeRewardRatio.Sub(starting.CumulativeRewardRatio) if difference.IsAnyNegative() { - return sdk.DecCoins{}, fmt.Errorf("negative rewards should not be possible") + return sdk.DecCoins{}, errors.New("negative rewards should not be possible") } // note: necessary to truncate so we don't allow withdrawing more rewards than owed rewards := difference.MulDecTruncate(stake) diff --git a/x/distribution/types/params.go b/x/distribution/types/params.go index b8438ca73812..b37cd8844fe1 100644 --- a/x/distribution/types/params.go +++ b/x/distribution/types/params.go @@ -1,6 +1,7 @@ package types import ( + "errors" "fmt" "cosmossdk.io/math" @@ -28,7 +29,7 @@ func validateCommunityTax(i interface{}) error { } if v.IsNil() { - return fmt.Errorf("community tax must be not nil") + return errors.New("community tax must be not nil") } if v.IsNegative() { return fmt.Errorf("community tax must be positive: %s", v) diff --git a/x/evidence/types/genesis.go b/x/evidence/types/genesis.go index e5c683831663..ce9363f58025 100644 --- a/x/evidence/types/genesis.go +++ b/x/evidence/types/genesis.go @@ -1,6 +1,7 @@ package types import ( + "errors" "fmt" "github.com/cosmos/gogoproto/proto" @@ -45,7 +46,7 @@ func (gs GenesisState) Validate() error { for _, e := range gs.Evidence { evi, ok := e.GetCachedValue().(exported.Evidence) if !ok { - return fmt.Errorf("expected evidence") + return errors.New("expected evidence") } if err := evi.ValidateBasic(); err != nil { return err diff --git a/x/feegrant/basic_fee.go b/x/feegrant/basic_fee.go index 1bace70b02ed..2100cd5be3b1 100644 --- a/x/feegrant/basic_fee.go +++ b/x/feegrant/basic_fee.go @@ -2,7 +2,7 @@ package feegrant import ( "context" - "fmt" + "errors" "time" "cosmossdk.io/core/appmodule" @@ -28,7 +28,7 @@ var _ FeeAllowanceI = (*BasicAllowance)(nil) func (a *BasicAllowance) Accept(ctx context.Context, fee sdk.Coins, _ []sdk.Msg) (bool, error) { environment, ok := ctx.Value(corecontext.EnvironmentContextKey).(appmodule.Environment) if !ok { - return false, fmt.Errorf("environment not set") + return false, errors.New("environment not set") } headerInfo := environment.HeaderService.HeaderInfo(ctx) if a.Expiration != nil && a.Expiration.Before(headerInfo.Time) { diff --git a/x/feegrant/filtered_fee.go b/x/feegrant/filtered_fee.go index a6c0d537a3f6..68e2fa681cfd 100644 --- a/x/feegrant/filtered_fee.go +++ b/x/feegrant/filtered_fee.go @@ -2,7 +2,7 @@ package feegrant import ( "context" - "fmt" + "errors" "time" "github.com/cosmos/gogoproto/proto" @@ -100,7 +100,7 @@ func (a *AllowedMsgAllowance) allowedMsgsToMap(ctx context.Context) (map[string] msgsMap := make(map[string]bool, len(a.AllowedMessages)) environment, ok := ctx.Value(corecontext.EnvironmentContextKey).(appmodule.Environment) if !ok { - return nil, fmt.Errorf("environment not set") + return nil, errors.New("environment not set") } gasMeter := environment.GasService.GasMeter(ctx) for _, msg := range a.AllowedMessages { @@ -120,7 +120,7 @@ func (a *AllowedMsgAllowance) allMsgTypesAllowed(ctx context.Context, msgs []sdk } environment, ok := ctx.Value(corecontext.EnvironmentContextKey).(appmodule.Environment) if !ok { - return false, fmt.Errorf("environment not set") + return false, errors.New("environment not set") } gasMeter := environment.GasService.GasMeter(ctx) for _, msg := range msgs { diff --git a/x/genutil/client/cli/export_test.go b/x/genutil/client/cli/export_test.go index e492e100b11f..f5f8c570d334 100644 --- a/x/genutil/client/cli/export_test.go +++ b/x/genutil/client/cli/export_test.go @@ -3,7 +3,7 @@ package cli_test import ( "context" "encoding/json" - "fmt" + "errors" "io" "os" "path/filepath" @@ -164,7 +164,7 @@ func (e *mockExporter) Export( modulesToExport []string, ) (types.ExportedApp, error) { if e.Err == nil && isZeroExportedApp(e.ExportApp) { - panic(fmt.Errorf("(*mockExporter).Export called without setting e.ExportApp or e.Err")) + panic(errors.New("(*mockExporter).Export called without setting e.ExportApp or e.Err")) } e.WasCalled = true @@ -311,7 +311,7 @@ func TestExportCLI(t *testing.T) { t.Parallel() e := new(mockExporter) - e.Err = fmt.Errorf("whoopsie") + e.Err = errors.New("whoopsie") sys := NewExportSystem(t, e.Export) _ = sys.MustRun(t, "init", "some_moniker") diff --git a/x/genutil/utils.go b/x/genutil/utils.go index e06e440d9a20..b20b7bfa6ec8 100644 --- a/x/genutil/utils.go +++ b/x/genutil/utils.go @@ -2,6 +2,7 @@ package genutil import ( "encoding/json" + "errors" "fmt" "os" "path/filepath" @@ -60,7 +61,7 @@ func InitializeNodeValidatorFilesFromMnemonic(config *cfg.Config, mnemonic, keyT nodeID string, valPubKey cryptotypes.PubKey, err error, ) { if len(mnemonic) > 0 && !bip39.IsMnemonicValid(mnemonic) { - return "", nil, fmt.Errorf("invalid mnemonic") + return "", nil, errors.New("invalid mnemonic") } nodeKey, err := p2p.LoadOrGenNodeKey(config.NodeKeyFile()) if err != nil { @@ -103,7 +104,7 @@ func InitializeNodeValidatorFilesFromMnemonic(config *cfg.Config, mnemonic, keyT privKey = tmed25519.GenPrivKeyFromSecret([]byte(mnemonic)) case "bls12_381": // TODO: need to add support for getting from mnemonic in Comet. - return "", nil, fmt.Errorf("BLS key type does not support mnemonic") + return "", nil, errors.New("BLS key type does not support mnemonic") default: privKey = tmed25519.GenPrivKeyFromSecret([]byte(mnemonic)) } diff --git a/x/gov/client/cli/util.go b/x/gov/client/cli/util.go index 166a4c7077da..f8628f9cffed 100644 --- a/x/gov/client/cli/util.go +++ b/x/gov/client/cli/util.go @@ -2,6 +2,7 @@ package cli import ( "encoding/json" + "errors" "fmt" "os" "strings" @@ -28,15 +29,15 @@ type legacyProposal struct { // validate the legacyProposal func (p legacyProposal) validate() error { if p.Type == "" { - return fmt.Errorf("proposal type is required") + return errors.New("proposal type is required") } if p.Title == "" { - return fmt.Errorf("proposal title is required") + return errors.New("proposal title is required") } if p.Description == "" { - return fmt.Errorf("proposal description is required") + return errors.New("proposal description is required") } return nil } diff --git a/x/gov/keeper/common_test.go b/x/gov/keeper/common_test.go index 595312521ed8..7a59f7e5a42e 100644 --- a/x/gov/keeper/common_test.go +++ b/x/gov/keeper/common_test.go @@ -1,6 +1,7 @@ package keeper_test import ( + "errors" "fmt" "testing" "time" @@ -266,7 +267,7 @@ func trackMockBalances(bankKeeper *govtestutil.MockBankKeeper) error { } newBalance, negative := balances[senderAddr].SafeSub(coins...) if negative { - return fmt.Errorf("not enough balance") + return errors.New("not enough balance") } balances[senderAddr] = newBalance return nil diff --git a/x/group/client/cli/util.go b/x/group/client/cli/util.go index 7b5cc7359155..162a7addd310 100644 --- a/x/group/client/cli/util.go +++ b/x/group/client/cli/util.go @@ -2,6 +2,7 @@ package cli import ( "encoding/json" + "errors" "fmt" "os" @@ -14,7 +15,7 @@ import ( // parseDecisionPolicy reads and parses the decision policy. func parseDecisionPolicy(cdc codec.Codec, decisionPolicyFile string) (group.DecisionPolicy, error) { if decisionPolicyFile == "" { - return nil, fmt.Errorf("decision policy is required") + return nil, errors.New("decision policy is required") } contents, err := os.ReadFile(decisionPolicyFile) diff --git a/x/group/internal/math/dec.go b/x/group/internal/math/dec.go index 02a0ca847678..973aa7024a40 100644 --- a/x/group/internal/math/dec.go +++ b/x/group/internal/math/dec.go @@ -2,12 +2,12 @@ package math import ( - "fmt" + "errors" "github.com/cockroachdb/apd/v2" errorsmod "cosmossdk.io/errors" - "cosmossdk.io/x/group/errors" + grouperrors "cosmossdk.io/x/group/errors" ) // Dec is a wrapper struct around apd.Decimal that does no mutation of apd.Decimal's when performing @@ -23,10 +23,10 @@ type Dec struct { func NewPositiveDecFromString(s string) (Dec, error) { d, err := NewDecFromString(s) if err != nil { - return Dec{}, errors.ErrInvalidDecString.Wrap(err.Error()) + return Dec{}, grouperrors.ErrInvalidDecString.Wrap(err.Error()) } if !d.IsPositive() { - return Dec{}, errors.ErrInvalidDecString.Wrapf("expected a positive decimal, got %s", s) + return Dec{}, grouperrors.ErrInvalidDecString.Wrapf("expected a positive decimal, got %s", s) } return d, nil } @@ -34,10 +34,10 @@ func NewPositiveDecFromString(s string) (Dec, error) { func NewNonNegativeDecFromString(s string) (Dec, error) { d, err := NewDecFromString(s) if err != nil { - return Dec{}, errors.ErrInvalidDecString.Wrap(err.Error()) + return Dec{}, grouperrors.ErrInvalidDecString.Wrap(err.Error()) } if d.IsNegative() { - return Dec{}, errors.ErrInvalidDecString.Wrapf("expected a non-negative decimal, got %s", s) + return Dec{}, grouperrors.ErrInvalidDecString.Wrapf("expected a non-negative decimal, got %s", s) } return d, nil } @@ -51,11 +51,11 @@ func (x Dec) IsPositive() bool { func NewDecFromString(s string) (Dec, error) { d, _, err := apd.NewFromString(s) if err != nil { - return Dec{}, errors.ErrInvalidDecString.Wrap(err.Error()) + return Dec{}, grouperrors.ErrInvalidDecString.Wrap(err.Error()) } if d.Form != apd.Finite { - return Dec{}, errors.ErrInvalidDecString.Wrapf("expected a finite decimal, got %s", s) + return Dec{}, grouperrors.ErrInvalidDecString.Wrapf("expected a finite decimal, got %s", s) } return Dec{*d}, nil @@ -136,7 +136,7 @@ func SubNonNegative(x, y Dec) (Dec, error) { } if z.IsNegative() { - return z, fmt.Errorf("result negative during non-negative subtraction") + return z, errors.New("result negative during non-negative subtraction") } return z, nil diff --git a/x/group/internal/orm/iterator.go b/x/group/internal/orm/iterator.go index a19d238e906d..c2612a4954fc 100644 --- a/x/group/internal/orm/iterator.go +++ b/x/group/internal/orm/iterator.go @@ -1,13 +1,13 @@ package orm import ( - "fmt" + "errors" "reflect" "github.com/cosmos/gogoproto/proto" errorsmod "cosmossdk.io/errors" - "cosmossdk.io/x/group/errors" + grouperrors "cosmossdk.io/x/group/errors" "github.com/cosmos/cosmos-sdk/types/query" ) @@ -20,7 +20,7 @@ const defaultPageLimit = 100 type IteratorFunc func(dest proto.Message) (RowID, error) // LoadNext loads the next value in the sequence into the pointer passed as dest and returns the key. If there -// are no more items the errors.ErrORMIteratorDone error is returned +// are no more items the grouperrors.ErrORMIteratorDone error is returned // The key is the rowID and not any MultiKeyIndex key. func (i IteratorFunc) LoadNext(dest proto.Message) (RowID, error) { return i(dest) @@ -35,10 +35,10 @@ func NewSingleValueIterator(rowID RowID, val []byte) Iterator { var closed bool return IteratorFunc(func(dest proto.Message) (RowID, error) { if dest == nil { - return nil, errorsmod.Wrap(errors.ErrORMInvalidArgument, "destination object must not be nil") + return nil, errorsmod.Wrap(grouperrors.ErrORMInvalidArgument, "destination object must not be nil") } if closed || val == nil { - return nil, errors.ErrORMIteratorDone + return nil, grouperrors.ErrORMIteratorDone } closed = true return rowID, proto.Unmarshal(val, dest) @@ -48,7 +48,7 @@ func NewSingleValueIterator(rowID RowID, val []byte) Iterator { // Iterator that return ErrORMInvalidIterator only. func NewInvalidIterator() Iterator { return IteratorFunc(func(dest proto.Message) (RowID, error) { - return nil, errors.ErrORMInvalidIterator + return nil, grouperrors.ErrORMInvalidIterator }) } @@ -63,20 +63,20 @@ type LimitedIterator struct { // max can be 0 or any positive number func LimitIterator(parent Iterator, max int) (*LimitedIterator, error) { if max < 0 { - return nil, errors.ErrORMInvalidArgument.Wrap("quantity must not be negative") + return nil, grouperrors.ErrORMInvalidArgument.Wrap("quantity must not be negative") } if parent == nil { - return nil, errors.ErrORMInvalidArgument.Wrap("parent iterator must not be nil") + return nil, grouperrors.ErrORMInvalidArgument.Wrap("parent iterator must not be nil") } return &LimitedIterator{remainingCount: max, parentIterator: parent}, nil } // LoadNext loads the next value in the sequence into the pointer passed as dest and returns the key. If there -// are no more items or the defined max number of elements was returned the `errors.ErrORMIteratorDone` error is returned +// are no more items or the defined max number of elements was returned the `grouperrors.ErrORMIteratorDone` error is returned // The key is the rowID and not any MultiKeyIndex key. func (i *LimitedIterator) LoadNext(dest proto.Message) (RowID, error) { if i.remainingCount == 0 { - return nil, errors.ErrORMIteratorDone + return nil, grouperrors.ErrORMIteratorDone } i.remainingCount-- return i.parentIterator.LoadNext(dest) @@ -91,7 +91,7 @@ func (i LimitedIterator) Close() error { // When the iterator is closed or has no elements the according error is passed as return value. func First(it Iterator, dest proto.Message) (RowID, error) { if it == nil { - return nil, errorsmod.Wrap(errors.ErrORMInvalidArgument, "iterator must not be nil") + return nil, errorsmod.Wrap(grouperrors.ErrORMInvalidArgument, "iterator must not be nil") } defer it.Close() binKey, err := it.LoadNext(dest) @@ -136,7 +136,7 @@ func Paginate( countTotal := pageRequest.CountTotal if offset > 0 && key != nil { - return nil, fmt.Errorf("invalid request, either offset or key is expected, got both") + return nil, errors.New("invalid request, either offset or key is expected, got both") } if limit == 0 { @@ -147,7 +147,7 @@ func Paginate( } if it == nil { - return nil, errorsmod.Wrap(errors.ErrORMInvalidArgument, "iterator must not be nil") + return nil, errorsmod.Wrap(grouperrors.ErrORMInvalidArgument, "iterator must not be nil") } defer it.Close() @@ -177,11 +177,11 @@ func Paginate( modelProto, ok := model.Interface().(proto.Message) if !ok { - return nil, errorsmod.Wrapf(errors.ErrORMInvalidArgument, "%s should implement codec.ProtoMarshaler", elemType) + return nil, errorsmod.Wrapf(grouperrors.ErrORMInvalidArgument, "%s should implement codec.ProtoMarshaler", elemType) } binKey, err := it.LoadNext(modelProto) if err != nil { - if errors.ErrORMIteratorDone.Is(err) { + if grouperrors.ErrORMIteratorDone.Is(err) { break } return nil, err @@ -237,7 +237,7 @@ type ModelSlicePtr interface{} // require.NoError(t, err) func ReadAll(it Iterator, dest ModelSlicePtr) ([]RowID, error) { if it == nil { - return nil, errorsmod.Wrap(errors.ErrORMInvalidArgument, "iterator must not be nil") + return nil, errorsmod.Wrap(grouperrors.ErrORMInvalidArgument, "iterator must not be nil") } defer it.Close() @@ -261,7 +261,7 @@ func ReadAll(it Iterator, dest ModelSlicePtr) ([]RowID, error) { switch { case err == nil: tmpSlice = reflect.Append(tmpSlice, val) - case errors.ErrORMIteratorDone.Is(err): + case grouperrors.ErrORMIteratorDone.Is(err): destRef.Set(tmpSlice) return rowIDs, nil default: @@ -276,14 +276,14 @@ func ReadAll(it Iterator, dest ModelSlicePtr) ([]RowID, error) { // It overwrites destRef and tmpSlice using reflection. func assertDest(dest ModelSlicePtr, destRef, tmpSlice *reflect.Value) (reflect.Type, error) { if dest == nil { - return nil, errorsmod.Wrap(errors.ErrORMInvalidArgument, "destination must not be nil") + return nil, errorsmod.Wrap(grouperrors.ErrORMInvalidArgument, "destination must not be nil") } tp := reflect.ValueOf(dest) if tp.Kind() != reflect.Ptr { - return nil, errorsmod.Wrap(errors.ErrORMInvalidArgument, "destination must be a pointer to a slice") + return nil, errorsmod.Wrap(grouperrors.ErrORMInvalidArgument, "destination must be a pointer to a slice") } if tp.Elem().Kind() != reflect.Slice { - return nil, errorsmod.Wrap(errors.ErrORMInvalidArgument, "destination must point to a slice") + return nil, errorsmod.Wrap(grouperrors.ErrORMInvalidArgument, "destination must point to a slice") } // Since dest is just an interface{}, we overwrite destRef using reflection @@ -291,7 +291,7 @@ func assertDest(dest ModelSlicePtr, destRef, tmpSlice *reflect.Value) (reflect.T *destRef = tp.Elem() // We need to verify that we can call Set() on destRef. if !destRef.CanSet() { - return nil, errorsmod.Wrap(errors.ErrORMInvalidArgument, "destination not assignable") + return nil, errorsmod.Wrap(grouperrors.ErrORMInvalidArgument, "destination not assignable") } elemType := reflect.TypeOf(dest).Elem().Elem() @@ -299,7 +299,7 @@ func assertDest(dest ModelSlicePtr, destRef, tmpSlice *reflect.Value) (reflect.T protoMarshaler := reflect.TypeOf((*proto.Message)(nil)).Elem() if !elemType.Implements(protoMarshaler) && !reflect.PtrTo(elemType).Implements(protoMarshaler) { - return nil, errorsmod.Wrapf(errors.ErrORMInvalidArgument, "unsupported type :%s", elemType) + return nil, errorsmod.Wrapf(grouperrors.ErrORMInvalidArgument, "unsupported type :%s", elemType) } // tmpSlice is a slice value for the specified type diff --git a/x/group/keeper/msg_server_test.go b/x/group/keeper/msg_server_test.go index 20eb8a7b184b..b3100a50287f 100644 --- a/x/group/keeper/msg_server_test.go +++ b/x/group/keeper/msg_server_test.go @@ -3,7 +3,7 @@ package keeper_test import ( "bytes" "context" - "fmt" + "errors" "sort" "strings" "time" @@ -2706,7 +2706,7 @@ func (s *TestSuite) TestExecProposal() { setupProposal: func(ctx context.Context) uint64 { msgs := []sdk.Msg{msgSend1, msgSend2} s.bankKeeper.EXPECT().Send(gomock.Any(), msgSend1).Return(nil, nil) - s.bankKeeper.EXPECT().Send(gomock.Any(), msgSend2).Return(nil, fmt.Errorf("error")) + s.bankKeeper.EXPECT().Send(gomock.Any(), msgSend2).Return(nil, errors.New("error")) return submitProposalAndVote(ctx, s, msgs, proposers, group.VOTE_OPTION_YES) }, @@ -2723,7 +2723,7 @@ func (s *TestSuite) TestExecProposal() { // Wait after min execution period end before Exec sdkCtx := sdk.UnwrapSDKContext(ctx) sdkCtx = sdkCtx.WithHeaderInfo(header.Info{Time: sdkCtx.HeaderInfo().Time.Add(minExecutionPeriod)}) // MinExecutionPeriod is 5s - s.bankKeeper.EXPECT().Send(gomock.Any(), msgSend2).Return(nil, fmt.Errorf("error")) + s.bankKeeper.EXPECT().Send(gomock.Any(), msgSend2).Return(nil, errors.New("error")) _, err := s.groupKeeper.Exec(sdkCtx, &group.MsgExec{Executor: s.addrsStr[0], ProposalId: myProposalID}) s.bankKeeper.EXPECT().Send(gomock.Any(), msgSend2).Return(nil, nil) @@ -2902,7 +2902,7 @@ func (s *TestSuite) TestExecPrunedProposalsAndVotes() { } msgs := []sdk.Msg{msgSend1, msgSend2} - s.bankKeeper.EXPECT().Send(gomock.Any(), msgSend1).Return(nil, fmt.Errorf("error")) + s.bankKeeper.EXPECT().Send(gomock.Any(), msgSend1).Return(nil, errors.New("error")) return submitProposalAndVote(ctx, s, msgs, proposers, group.VOTE_OPTION_YES) }, @@ -2920,7 +2920,7 @@ func (s *TestSuite) TestExecPrunedProposalsAndVotes() { myProposalID := submitProposalAndVote(ctx, s, msgs, proposers, group.VOTE_OPTION_YES) - s.bankKeeper.EXPECT().Send(gomock.Any(), msgSend2).Return(nil, fmt.Errorf("error")) + s.bankKeeper.EXPECT().Send(gomock.Any(), msgSend2).Return(nil, errors.New("error")) // Wait for min execution period end sdkCtx := sdk.UnwrapSDKContext(ctx) From fa612ef9d7dad49ea489471a21dd1ed4410595ea Mon Sep 17 00:00:00 2001 From: sjtucoder Date: Tue, 23 Jul 2024 17:36:49 +0900 Subject: [PATCH 27/50] chore: fix some comments for struct field (#21027) Signed-off-by: sjtucoder --- api/cosmos/nft/v1beta1/query_grpc.pb.go | 4 ++-- client/docs/swagger-ui/swagger.yaml | 2 +- x/nft/proto/cosmos/nft/v1beta1/query.proto | 2 +- x/nft/query.pb.go | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/api/cosmos/nft/v1beta1/query_grpc.pb.go b/api/cosmos/nft/v1beta1/query_grpc.pb.go index d25acc384af2..1f69c3c9643e 100644 --- a/api/cosmos/nft/v1beta1/query_grpc.pb.go +++ b/api/cosmos/nft/v1beta1/query_grpc.pb.go @@ -39,7 +39,7 @@ const ( type QueryClient interface { // Balance queries the number of NFTs of a given class owned by the owner, same as balanceOf in ERC721 Balance(ctx context.Context, in *QueryBalanceRequest, opts ...grpc.CallOption) (*QueryBalanceResponse, error) - // BalancebyQueryString queries the number of NFTs of a given class owned by the owner, same as balanceOf in ERC721 + // BalanceByQueryString queries the number of NFTs of a given class owned by the owner, same as balanceOf in ERC721 BalanceByQueryString(ctx context.Context, in *QueryBalanceByQueryStringRequest, opts ...grpc.CallOption) (*QueryBalanceByQueryStringResponse, error) // Owner queries the owner of the NFT based on its class and id, same as ownerOf in ERC721 Owner(ctx context.Context, in *QueryOwnerRequest, opts ...grpc.CallOption) (*QueryOwnerResponse, error) @@ -186,7 +186,7 @@ func (c *queryClient) Classes(ctx context.Context, in *QueryClassesRequest, opts type QueryServer interface { // Balance queries the number of NFTs of a given class owned by the owner, same as balanceOf in ERC721 Balance(context.Context, *QueryBalanceRequest) (*QueryBalanceResponse, error) - // BalancebyQueryString queries the number of NFTs of a given class owned by the owner, same as balanceOf in ERC721 + // BalanceByQueryString queries the number of NFTs of a given class owned by the owner, same as balanceOf in ERC721 BalanceByQueryString(context.Context, *QueryBalanceByQueryStringRequest) (*QueryBalanceByQueryStringResponse, error) // Owner queries the owner of the NFT based on its class and id, same as ownerOf in ERC721 Owner(context.Context, *QueryOwnerRequest) (*QueryOwnerResponse, error) diff --git a/client/docs/swagger-ui/swagger.yaml b/client/docs/swagger-ui/swagger.yaml index f949019cfdd8..c4352f47aec5 100644 --- a/client/docs/swagger-ui/swagger.yaml +++ b/client/docs/swagger-ui/swagger.yaml @@ -29831,7 +29831,7 @@ paths: /cosmos/nft/v1beta1/balance: get: summary: >- - BalancebyQueryString queries the number of NFTs of a given class owned + BalanceByQueryString queries the number of NFTs of a given class owned by the owner, same as balanceOf in ERC721 operationId: BalanceByQueryString responses: diff --git a/x/nft/proto/cosmos/nft/v1beta1/query.proto b/x/nft/proto/cosmos/nft/v1beta1/query.proto index e0646c61fe38..92df51459e41 100644 --- a/x/nft/proto/cosmos/nft/v1beta1/query.proto +++ b/x/nft/proto/cosmos/nft/v1beta1/query.proto @@ -15,7 +15,7 @@ service Query { option (google.api.http).get = "/cosmos/nft/v1beta1/balance/{owner}/{class_id}"; } - // BalancebyQueryString queries the number of NFTs of a given class owned by the owner, same as balanceOf in ERC721 + // BalanceByQueryString queries the number of NFTs of a given class owned by the owner, same as balanceOf in ERC721 rpc BalanceByQueryString(QueryBalanceByQueryStringRequest) returns (QueryBalanceByQueryStringResponse) { option (google.api.http).get = "/cosmos/nft/v1beta1/balance"; option (cosmos_proto.method_added_in) = "nft v0.1.1"; diff --git a/x/nft/query.pb.go b/x/nft/query.pb.go index c815738d61ae..7b9138320b12 100644 --- a/x/nft/query.pb.go +++ b/x/nft/query.pb.go @@ -1333,7 +1333,7 @@ const _ = grpc.SupportPackageIsVersion4 type QueryClient interface { // Balance queries the number of NFTs of a given class owned by the owner, same as balanceOf in ERC721 Balance(ctx context.Context, in *QueryBalanceRequest, opts ...grpc.CallOption) (*QueryBalanceResponse, error) - // BalancebyQueryString queries the number of NFTs of a given class owned by the owner, same as balanceOf in ERC721 + // BalanceByQueryString queries the number of NFTs of a given class owned by the owner, same as balanceOf in ERC721 BalanceByQueryString(ctx context.Context, in *QueryBalanceByQueryStringRequest, opts ...grpc.CallOption) (*QueryBalanceByQueryStringResponse, error) // Owner queries the owner of the NFT based on its class and id, same as ownerOf in ERC721 Owner(ctx context.Context, in *QueryOwnerRequest, opts ...grpc.CallOption) (*QueryOwnerResponse, error) @@ -1478,7 +1478,7 @@ func (c *queryClient) Classes(ctx context.Context, in *QueryClassesRequest, opts type QueryServer interface { // Balance queries the number of NFTs of a given class owned by the owner, same as balanceOf in ERC721 Balance(context.Context, *QueryBalanceRequest) (*QueryBalanceResponse, error) - // BalancebyQueryString queries the number of NFTs of a given class owned by the owner, same as balanceOf in ERC721 + // BalanceByQueryString queries the number of NFTs of a given class owned by the owner, same as balanceOf in ERC721 BalanceByQueryString(context.Context, *QueryBalanceByQueryStringRequest) (*QueryBalanceByQueryStringResponse, error) // Owner queries the owner of the NFT based on its class and id, same as ownerOf in ERC721 Owner(context.Context, *QueryOwnerRequest) (*QueryOwnerResponse, error) From 7501ccd700df42dba09f868be6f102286c832ac3 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 23 Jul 2024 10:37:41 +0200 Subject: [PATCH 28/50] build(deps): Bump bufbuild/buf-setup-action from 1.34.0 to 1.35.0 (#21028) Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/proto.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/proto.yml b/.github/workflows/proto.yml index 998b9ac993b1..3302e6edc82d 100644 --- a/.github/workflows/proto.yml +++ b/.github/workflows/proto.yml @@ -15,7 +15,7 @@ jobs: timeout-minutes: 5 steps: - uses: actions/checkout@v4 - - uses: bufbuild/buf-setup-action@v1.34.0 + - uses: bufbuild/buf-setup-action@v1.35.0 - uses: bufbuild/buf-lint-action@v1 with: input: "proto" @@ -24,7 +24,7 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - uses: bufbuild/buf-setup-action@v1.34.0 + - uses: bufbuild/buf-setup-action@v1.35.0 - uses: bufbuild/buf-breaking-action@v1 with: input: "proto" From 544623f3b7093fea37d4f409b13b75dff2604387 Mon Sep 17 00:00:00 2001 From: Julien Robert Date: Tue, 23 Jul 2024 11:08:41 +0200 Subject: [PATCH 29/50] build(deps): add missing replaces and remove unnecessary ones (#21033) --- client/v2/go.mod | 3 +-- client/v2/go.sum | 2 ++ go.mod | 3 +-- go.sum | 2 ++ orm/go.mod | 7 ++----- orm/go.sum | 2 ++ runtime/v2/go.mod | 3 +-- runtime/v2/go.sum | 2 ++ server/v2/cometbft/go.mod | 3 +-- server/v2/cometbft/go.sum | 2 ++ server/v2/go.mod | 1 - simapp/go.mod | 3 +-- simapp/go.sum | 2 ++ simapp/v2/go.mod | 3 +-- simapp/v2/go.sum | 2 ++ tests/go.mod | 3 +-- tests/go.sum | 2 ++ tests/systemtests/go.mod | 2 +- tests/systemtests/go.sum | 4 ++-- tools/confix/go.mod | 2 +- tools/confix/go.sum | 4 ++-- tools/cosmovisor/go.mod | 2 +- tools/cosmovisor/go.sum | 4 ++-- tools/hubl/go.mod | 2 +- tools/hubl/go.sum | 4 ++-- x/accounts/defaults/lockup/go.mod | 3 +-- x/accounts/defaults/lockup/go.sum | 2 ++ x/accounts/defaults/multisig/go.mod | 4 ++-- x/accounts/defaults/multisig/go.sum | 4 ++-- x/accounts/go.mod | 3 +-- x/accounts/go.sum | 2 ++ x/auth/go.mod | 3 +-- x/auth/go.sum | 2 ++ x/authz/go.mod | 4 +--- x/authz/go.sum | 2 ++ x/bank/go.mod | 3 +-- x/bank/go.sum | 2 ++ x/circuit/go.mod | 3 +-- x/circuit/go.sum | 2 ++ x/consensus/go.mod | 3 +-- x/consensus/go.sum | 2 ++ x/distribution/go.mod | 3 +-- x/distribution/go.sum | 2 ++ x/epochs/go.mod | 3 +-- x/epochs/go.sum | 2 ++ x/evidence/go.mod | 3 +-- x/evidence/go.sum | 2 ++ x/feegrant/go.mod | 10 +++------- x/feegrant/go.sum | 2 ++ x/gov/go.mod | 6 ++---- x/gov/go.sum | 2 ++ x/group/go.mod | 3 +-- x/group/go.sum | 2 ++ x/mint/go.mod | 3 +-- x/mint/go.sum | 2 ++ x/nft/go.mod | 3 +-- x/nft/go.sum | 2 ++ x/params/go.mod | 3 +-- x/params/go.sum | 2 ++ x/protocolpool/go.mod | 3 +-- x/protocolpool/go.sum | 2 ++ x/slashing/go.mod | 3 +-- x/slashing/go.sum | 2 ++ x/staking/go.mod | 3 +-- x/staking/go.sum | 2 ++ x/upgrade/go.mod | 3 +-- x/upgrade/go.sum | 2 ++ 67 files changed, 104 insertions(+), 84 deletions(-) diff --git a/client/v2/go.mod b/client/v2/go.mod index a9bb7f4a8e15..d6e3d4e93680 100644 --- a/client/v2/go.mod +++ b/client/v2/go.mod @@ -5,7 +5,7 @@ go 1.22.2 require ( cosmossdk.io/api v0.7.5 cosmossdk.io/core v0.12.1-0.20231114100755-569e3ff6a0d7 - cosmossdk.io/depinject v1.0.0-alpha.4 + cosmossdk.io/depinject v1.0.0 cosmossdk.io/x/bank v0.0.0-20240226161501-23359a0b6d91 cosmossdk.io/x/gov v0.0.0-20231113122742-912390d5fc4a cosmossdk.io/x/tx v0.13.3 @@ -183,7 +183,6 @@ replace ( cosmossdk.io/api => ./../../api cosmossdk.io/core => ./../../core cosmossdk.io/core/testing => ../../core/testing - cosmossdk.io/depinject => ./../../depinject cosmossdk.io/log => ./../../log cosmossdk.io/store => ./../../store cosmossdk.io/x/accounts => ./../../x/accounts diff --git a/client/v2/go.sum b/client/v2/go.sum index 0b4d456bb56c..cd9dd4c5e9c8 100644 --- a/client/v2/go.sum +++ b/client/v2/go.sum @@ -6,6 +6,8 @@ cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMT cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= cosmossdk.io/collections v0.4.0 h1:PFmwj2W8szgpD5nOd8GWH6AbYNi1f2J6akWXJ7P5t9s= cosmossdk.io/collections v0.4.0/go.mod h1:oa5lUING2dP+gdDquow+QjlF45eL1t4TJDypgGd+tv0= +cosmossdk.io/depinject v1.0.0 h1:dQaTu6+O6askNXO06+jyeUAnF2/ssKwrrszP9t5q050= +cosmossdk.io/depinject v1.0.0/go.mod h1:zxK/h3HgHoA/eJVtiSsoaRaRA2D5U4cJ5thIG4ssbB8= cosmossdk.io/errors v1.0.1 h1:bzu+Kcr0kS/1DuPBtUFdWjzLqyUuCiyHjyJB6srBV/0= cosmossdk.io/errors v1.0.1/go.mod h1:MeelVSZThMi4bEakzhhhE/CKqVv3nOJDA25bIqRDu/U= cosmossdk.io/math v1.3.0 h1:RC+jryuKeytIiictDslBP9i1fhkVm6ZDmZEoNP316zE= diff --git a/go.mod b/go.mod index b575c28b25bd..00df79575de4 100644 --- a/go.mod +++ b/go.mod @@ -7,7 +7,7 @@ require ( cosmossdk.io/collections v0.4.0 cosmossdk.io/core v0.12.1-0.20231114100755-569e3ff6a0d7 cosmossdk.io/core/testing v0.0.0-00010101000000-000000000000 - cosmossdk.io/depinject v1.0.0-alpha.4 + cosmossdk.io/depinject v1.0.0 cosmossdk.io/errors v1.0.1 cosmossdk.io/log v1.3.1 cosmossdk.io/math v1.3.0 @@ -188,7 +188,6 @@ replace ( cosmossdk.io/collections => ./collections cosmossdk.io/core => ./core cosmossdk.io/core/testing => ./core/testing - cosmossdk.io/depinject => ./depinject cosmossdk.io/log => ./log cosmossdk.io/store => ./store cosmossdk.io/x/accounts => ./x/accounts diff --git a/go.sum b/go.sum index 1cb148b54b7d..d990868be5f0 100644 --- a/go.sum +++ b/go.sum @@ -4,6 +4,8 @@ buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.34.2-20240130113600-88e buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.34.2-20240130113600-88ef6483f90f.2/go.mod h1:HqcXMSa5qnNuakaMUo+hWhF51mKbcrZxGl9Vp5EeJXc= cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= +cosmossdk.io/depinject v1.0.0 h1:dQaTu6+O6askNXO06+jyeUAnF2/ssKwrrszP9t5q050= +cosmossdk.io/depinject v1.0.0/go.mod h1:zxK/h3HgHoA/eJVtiSsoaRaRA2D5U4cJ5thIG4ssbB8= cosmossdk.io/errors v1.0.1 h1:bzu+Kcr0kS/1DuPBtUFdWjzLqyUuCiyHjyJB6srBV/0= cosmossdk.io/errors v1.0.1/go.mod h1:MeelVSZThMi4bEakzhhhE/CKqVv3nOJDA25bIqRDu/U= cosmossdk.io/math v1.3.0 h1:RC+jryuKeytIiictDslBP9i1fhkVm6ZDmZEoNP316zE= diff --git a/orm/go.mod b/orm/go.mod index 86c7619af94c..7a290f798bff 100644 --- a/orm/go.mod +++ b/orm/go.mod @@ -5,7 +5,7 @@ go 1.21 require ( cosmossdk.io/api v0.7.5 cosmossdk.io/core v0.12.1-0.20231114100755-569e3ff6a0d7 - cosmossdk.io/depinject v1.0.0-alpha.4 + cosmossdk.io/depinject v1.0.0 cosmossdk.io/errors v1.0.1 github.com/cosmos/cosmos-db v1.0.2 github.com/cosmos/cosmos-proto v1.0.0-beta.5 @@ -68,7 +68,4 @@ require ( sigs.k8s.io/yaml v1.4.0 // indirect ) -replace ( - cosmossdk.io/core => ../core - cosmossdk.io/depinject => ../depinject -) +replace cosmossdk.io/core => ../core diff --git a/orm/go.sum b/orm/go.sum index ace3ac645255..4382ea973b42 100644 --- a/orm/go.sum +++ b/orm/go.sum @@ -1,5 +1,7 @@ cosmossdk.io/api v0.7.5 h1:eMPTReoNmGUm8DeiQL9DyM8sYDjEhWzL1+nLbI9DqtQ= cosmossdk.io/api v0.7.5/go.mod h1:IcxpYS5fMemZGqyYtErK7OqvdM0C8kdW3dq8Q/XIG38= +cosmossdk.io/depinject v1.0.0 h1:dQaTu6+O6askNXO06+jyeUAnF2/ssKwrrszP9t5q050= +cosmossdk.io/depinject v1.0.0/go.mod h1:zxK/h3HgHoA/eJVtiSsoaRaRA2D5U4cJ5thIG4ssbB8= cosmossdk.io/errors v1.0.1 h1:bzu+Kcr0kS/1DuPBtUFdWjzLqyUuCiyHjyJB6srBV/0= cosmossdk.io/errors v1.0.1/go.mod h1:MeelVSZThMi4bEakzhhhE/CKqVv3nOJDA25bIqRDu/U= github.com/DataDog/zstd v1.5.5 h1:oWf5W7GtOLgp6bciQYDmhHHjdhYkALu6S/5Ni9ZgSvQ= diff --git a/runtime/v2/go.mod b/runtime/v2/go.mod index 3873280d2b38..50c759c959b6 100644 --- a/runtime/v2/go.mod +++ b/runtime/v2/go.mod @@ -7,7 +7,6 @@ replace ( cosmossdk.io/api => ../../api cosmossdk.io/core => ../../core cosmossdk.io/core/testing => ../../core/testing - cosmossdk.io/depinject => ../../depinject cosmossdk.io/log => ../../log cosmossdk.io/server/v2/appmanager => ../../server/v2/appmanager cosmossdk.io/server/v2/stf => ../../server/v2/stf @@ -25,7 +24,7 @@ replace ( require ( cosmossdk.io/api v0.7.5 cosmossdk.io/core v0.12.1-0.20231114100755-569e3ff6a0d7 - cosmossdk.io/depinject v1.0.0-alpha.4 + cosmossdk.io/depinject v1.0.0 cosmossdk.io/server/v2/appmanager v0.0.0-00010101000000-000000000000 cosmossdk.io/server/v2/stf v0.0.0-00010101000000-000000000000 cosmossdk.io/store/v2 v2.0.0-00010101000000-000000000000 diff --git a/runtime/v2/go.sum b/runtime/v2/go.sum index 069bd8c96bf4..3f00d777d26a 100644 --- a/runtime/v2/go.sum +++ b/runtime/v2/go.sum @@ -2,6 +2,8 @@ buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.34.2-20240701160653-fed buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.34.2-20240701160653-fedbb9acfd2f.2/go.mod h1:1+3gJj2NvZ1mTLAtHu+lMhOjGgQPiCKCeo+9MBww0Eo= buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.34.2-20240130113600-88ef6483f90f.2 h1:b7EEYTUHmWSBEyISHlHvXbJPqtKiHRuUignL1tsHnNQ= buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.34.2-20240130113600-88ef6483f90f.2/go.mod h1:HqcXMSa5qnNuakaMUo+hWhF51mKbcrZxGl9Vp5EeJXc= +cosmossdk.io/depinject v1.0.0 h1:dQaTu6+O6askNXO06+jyeUAnF2/ssKwrrszP9t5q050= +cosmossdk.io/depinject v1.0.0/go.mod h1:zxK/h3HgHoA/eJVtiSsoaRaRA2D5U4cJ5thIG4ssbB8= cosmossdk.io/errors v1.0.1 h1:bzu+Kcr0kS/1DuPBtUFdWjzLqyUuCiyHjyJB6srBV/0= cosmossdk.io/errors v1.0.1/go.mod h1:MeelVSZThMi4bEakzhhhE/CKqVv3nOJDA25bIqRDu/U= github.com/DataDog/datadog-go v3.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ= diff --git a/server/v2/cometbft/go.mod b/server/v2/cometbft/go.mod index 2d3aebb30984..b33ca719aef4 100644 --- a/server/v2/cometbft/go.mod +++ b/server/v2/cometbft/go.mod @@ -6,7 +6,6 @@ replace ( cosmossdk.io/api => ../../../api cosmossdk.io/core => ../../../core cosmossdk.io/core/testing => ../../../core/testing - cosmossdk.io/depinject => ../../../depinject cosmossdk.io/log => ../../../log cosmossdk.io/server/v2 => ../ cosmossdk.io/server/v2/appmanager => ../appmanager @@ -50,7 +49,7 @@ require ( buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.34.2-20240130113600-88ef6483f90f.2 // indirect cosmossdk.io/collections v0.4.0 // indirect cosmossdk.io/core/testing v0.0.0-00010101000000-000000000000 // indirect - cosmossdk.io/depinject v1.0.0-alpha.4 // indirect + cosmossdk.io/depinject v1.0.0 // indirect cosmossdk.io/log v1.3.1 // indirect cosmossdk.io/math v1.3.0 // indirect cosmossdk.io/schema v0.1.1 // indirect diff --git a/server/v2/cometbft/go.sum b/server/v2/cometbft/go.sum index c749a4e9d0d6..7ba20e510178 100644 --- a/server/v2/cometbft/go.sum +++ b/server/v2/cometbft/go.sum @@ -6,6 +6,8 @@ cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMT cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= cosmossdk.io/collections v0.4.0 h1:PFmwj2W8szgpD5nOd8GWH6AbYNi1f2J6akWXJ7P5t9s= cosmossdk.io/collections v0.4.0/go.mod h1:oa5lUING2dP+gdDquow+QjlF45eL1t4TJDypgGd+tv0= +cosmossdk.io/depinject v1.0.0 h1:dQaTu6+O6askNXO06+jyeUAnF2/ssKwrrszP9t5q050= +cosmossdk.io/depinject v1.0.0/go.mod h1:zxK/h3HgHoA/eJVtiSsoaRaRA2D5U4cJ5thIG4ssbB8= cosmossdk.io/errors v1.0.1 h1:bzu+Kcr0kS/1DuPBtUFdWjzLqyUuCiyHjyJB6srBV/0= cosmossdk.io/errors v1.0.1/go.mod h1:MeelVSZThMi4bEakzhhhE/CKqVv3nOJDA25bIqRDu/U= cosmossdk.io/math v1.3.0 h1:RC+jryuKeytIiictDslBP9i1fhkVm6ZDmZEoNP316zE= diff --git a/server/v2/go.mod b/server/v2/go.mod index 4ff5ab253eea..31e857839fa9 100644 --- a/server/v2/go.mod +++ b/server/v2/go.mod @@ -6,7 +6,6 @@ replace ( cosmossdk.io/api => ../../api cosmossdk.io/core => ../../core cosmossdk.io/core/testing => ../../core/testing - cosmossdk.io/depinject => ../../depinject cosmossdk.io/log => ../../log cosmossdk.io/server/v2/appmanager => ./appmanager cosmossdk.io/server/v2/stf => ./stf diff --git a/simapp/go.mod b/simapp/go.mod index c5238167f215..5d67518fce5a 100644 --- a/simapp/go.mod +++ b/simapp/go.mod @@ -8,7 +8,7 @@ require ( cosmossdk.io/collections v0.4.0 cosmossdk.io/core v0.12.1-0.20231114100755-569e3ff6a0d7 cosmossdk.io/core/testing v0.0.0-00010101000000-000000000000 - cosmossdk.io/depinject v1.0.0-alpha.4 + cosmossdk.io/depinject v1.0.0 cosmossdk.io/log v1.3.1 cosmossdk.io/math v1.3.0 cosmossdk.io/store v1.1.1-0.20240418092142-896cdf1971bc @@ -244,7 +244,6 @@ replace ( cosmossdk.io/collections => ../collections cosmossdk.io/core => ../core cosmossdk.io/core/testing => ../core/testing - cosmossdk.io/depinject => ../depinject cosmossdk.io/log => ../log cosmossdk.io/store => ../store cosmossdk.io/tools/confix => ../tools/confix diff --git a/simapp/go.sum b/simapp/go.sum index 11ad33d741a0..33e6ee51d3b2 100644 --- a/simapp/go.sum +++ b/simapp/go.sum @@ -192,6 +192,8 @@ cloud.google.com/go/webrisk v1.4.0/go.mod h1:Hn8X6Zr+ziE2aNd8SliSDWpEnSS1u4R9+xX cloud.google.com/go/webrisk v1.5.0/go.mod h1:iPG6fr52Tv7sGk0H6qUFzmL3HHZev1htXuWDEEsqMTg= cloud.google.com/go/workflows v1.6.0/go.mod h1:6t9F5h/unJz41YqfBmqSASJSXccBLtD1Vwf+KmJENM0= cloud.google.com/go/workflows v1.7.0/go.mod h1:JhSrZuVZWuiDfKEFxU0/F1PQjmpnpcoISEXH2bcHC3M= +cosmossdk.io/depinject v1.0.0 h1:dQaTu6+O6askNXO06+jyeUAnF2/ssKwrrszP9t5q050= +cosmossdk.io/depinject v1.0.0/go.mod h1:zxK/h3HgHoA/eJVtiSsoaRaRA2D5U4cJ5thIG4ssbB8= cosmossdk.io/errors v1.0.1 h1:bzu+Kcr0kS/1DuPBtUFdWjzLqyUuCiyHjyJB6srBV/0= cosmossdk.io/errors v1.0.1/go.mod h1:MeelVSZThMi4bEakzhhhE/CKqVv3nOJDA25bIqRDu/U= cosmossdk.io/math v1.3.0 h1:RC+jryuKeytIiictDslBP9i1fhkVm6ZDmZEoNP316zE= diff --git a/simapp/v2/go.mod b/simapp/v2/go.mod index a275758c69fc..535cf5c7ac0a 100644 --- a/simapp/v2/go.mod +++ b/simapp/v2/go.mod @@ -6,7 +6,7 @@ require ( cosmossdk.io/api v0.7.5 cosmossdk.io/client/v2 v2.0.0-00010101000000-000000000000 cosmossdk.io/core v0.12.1-0.20231114100755-569e3ff6a0d7 - cosmossdk.io/depinject v1.0.0-alpha.4 + cosmossdk.io/depinject v1.0.0 cosmossdk.io/log v1.3.1 cosmossdk.io/math v1.3.0 cosmossdk.io/runtime/v2 v2.0.0-00010101000000-000000000000 @@ -250,7 +250,6 @@ replace ( cosmossdk.io/client/v2 => ../../client/v2 cosmossdk.io/collections => ../../collections cosmossdk.io/core => ../../core - cosmossdk.io/depinject => ../../depinject cosmossdk.io/tools/confix => ../../tools/confix cosmossdk.io/x/accounts => ../../x/accounts cosmossdk.io/x/accounts/defaults/lockup => ../../x/accounts/defaults/lockup diff --git a/simapp/v2/go.sum b/simapp/v2/go.sum index 3e3ba62fee8d..b95c10d44d36 100644 --- a/simapp/v2/go.sum +++ b/simapp/v2/go.sum @@ -192,6 +192,8 @@ cloud.google.com/go/webrisk v1.4.0/go.mod h1:Hn8X6Zr+ziE2aNd8SliSDWpEnSS1u4R9+xX cloud.google.com/go/webrisk v1.5.0/go.mod h1:iPG6fr52Tv7sGk0H6qUFzmL3HHZev1htXuWDEEsqMTg= cloud.google.com/go/workflows v1.6.0/go.mod h1:6t9F5h/unJz41YqfBmqSASJSXccBLtD1Vwf+KmJENM0= cloud.google.com/go/workflows v1.7.0/go.mod h1:JhSrZuVZWuiDfKEFxU0/F1PQjmpnpcoISEXH2bcHC3M= +cosmossdk.io/depinject v1.0.0 h1:dQaTu6+O6askNXO06+jyeUAnF2/ssKwrrszP9t5q050= +cosmossdk.io/depinject v1.0.0/go.mod h1:zxK/h3HgHoA/eJVtiSsoaRaRA2D5U4cJ5thIG4ssbB8= cosmossdk.io/errors v1.0.1 h1:bzu+Kcr0kS/1DuPBtUFdWjzLqyUuCiyHjyJB6srBV/0= cosmossdk.io/errors v1.0.1/go.mod h1:MeelVSZThMi4bEakzhhhE/CKqVv3nOJDA25bIqRDu/U= cosmossdk.io/math v1.3.0 h1:RC+jryuKeytIiictDslBP9i1fhkVm6ZDmZEoNP316zE= diff --git a/tests/go.mod b/tests/go.mod index da3bc3b45cb2..e0ad26aa6b25 100644 --- a/tests/go.mod +++ b/tests/go.mod @@ -6,7 +6,7 @@ require ( cosmossdk.io/api v0.7.5 cosmossdk.io/collections v0.4.0 cosmossdk.io/core v0.12.1-0.20231114100755-569e3ff6a0d7 - cosmossdk.io/depinject v1.0.0-alpha.4 + cosmossdk.io/depinject v1.0.0 cosmossdk.io/errors v1.0.1 // indirect cosmossdk.io/log v1.3.1 cosmossdk.io/math v1.3.0 @@ -241,7 +241,6 @@ replace ( cosmossdk.io/collections => ../collections cosmossdk.io/core => ../core cosmossdk.io/core/testing => ../core/testing - cosmossdk.io/depinject => ../depinject cosmossdk.io/log => ../log cosmossdk.io/store => ../store cosmossdk.io/x/accounts => ../x/accounts diff --git a/tests/go.sum b/tests/go.sum index 934a3017d47a..5c9a5948ff5e 100644 --- a/tests/go.sum +++ b/tests/go.sum @@ -192,6 +192,8 @@ cloud.google.com/go/webrisk v1.4.0/go.mod h1:Hn8X6Zr+ziE2aNd8SliSDWpEnSS1u4R9+xX cloud.google.com/go/webrisk v1.5.0/go.mod h1:iPG6fr52Tv7sGk0H6qUFzmL3HHZev1htXuWDEEsqMTg= cloud.google.com/go/workflows v1.6.0/go.mod h1:6t9F5h/unJz41YqfBmqSASJSXccBLtD1Vwf+KmJENM0= cloud.google.com/go/workflows v1.7.0/go.mod h1:JhSrZuVZWuiDfKEFxU0/F1PQjmpnpcoISEXH2bcHC3M= +cosmossdk.io/depinject v1.0.0 h1:dQaTu6+O6askNXO06+jyeUAnF2/ssKwrrszP9t5q050= +cosmossdk.io/depinject v1.0.0/go.mod h1:zxK/h3HgHoA/eJVtiSsoaRaRA2D5U4cJ5thIG4ssbB8= cosmossdk.io/errors v1.0.1 h1:bzu+Kcr0kS/1DuPBtUFdWjzLqyUuCiyHjyJB6srBV/0= cosmossdk.io/errors v1.0.1/go.mod h1:MeelVSZThMi4bEakzhhhE/CKqVv3nOJDA25bIqRDu/U= cosmossdk.io/math v1.3.0 h1:RC+jryuKeytIiictDslBP9i1fhkVm6ZDmZEoNP316zE= diff --git a/tests/systemtests/go.mod b/tests/systemtests/go.mod index 7ff21661a355..e7c9ac0f2c4e 100644 --- a/tests/systemtests/go.mod +++ b/tests/systemtests/go.mod @@ -36,7 +36,7 @@ require ( cosmossdk.io/api v0.7.5 // indirect cosmossdk.io/collections v0.4.0 // indirect cosmossdk.io/core v0.11.0 // indirect - cosmossdk.io/depinject v1.0.0-alpha.4 // indirect + cosmossdk.io/depinject v1.0.0 // indirect cosmossdk.io/errors v1.0.1 // indirect cosmossdk.io/log v1.3.1 // indirect cosmossdk.io/store v1.1.0 // indirect diff --git a/tests/systemtests/go.sum b/tests/systemtests/go.sum index bed8c0c8f9c8..a0aa43940f9e 100644 --- a/tests/systemtests/go.sum +++ b/tests/systemtests/go.sum @@ -6,8 +6,8 @@ cosmossdk.io/collections v0.4.0 h1:PFmwj2W8szgpD5nOd8GWH6AbYNi1f2J6akWXJ7P5t9s= cosmossdk.io/collections v0.4.0/go.mod h1:oa5lUING2dP+gdDquow+QjlF45eL1t4TJDypgGd+tv0= cosmossdk.io/core v0.11.0 h1:vtIafqUi+1ZNAE/oxLOQQ7Oek2n4S48SWLG8h/+wdbo= cosmossdk.io/core v0.11.0/go.mod h1:LaTtayWBSoacF5xNzoF8tmLhehqlA9z1SWiPuNC6X1w= -cosmossdk.io/depinject v1.0.0-alpha.4 h1:PLNp8ZYAMPTUKyG9IK2hsbciDWqna2z1Wsl98okJopc= -cosmossdk.io/depinject v1.0.0-alpha.4/go.mod h1:HeDk7IkR5ckZ3lMGs/o91AVUc7E596vMaOmslGFM3yU= +cosmossdk.io/depinject v1.0.0 h1:dQaTu6+O6askNXO06+jyeUAnF2/ssKwrrszP9t5q050= +cosmossdk.io/depinject v1.0.0/go.mod h1:zxK/h3HgHoA/eJVtiSsoaRaRA2D5U4cJ5thIG4ssbB8= cosmossdk.io/errors v1.0.1 h1:bzu+Kcr0kS/1DuPBtUFdWjzLqyUuCiyHjyJB6srBV/0= cosmossdk.io/errors v1.0.1/go.mod h1:MeelVSZThMi4bEakzhhhE/CKqVv3nOJDA25bIqRDu/U= cosmossdk.io/log v1.3.1 h1:UZx8nWIkfbbNEWusZqzAx3ZGvu54TZacWib3EzUYmGI= diff --git a/tools/confix/go.mod b/tools/confix/go.mod index fc186fed6c14..d7c74d44b60b 100644 --- a/tools/confix/go.mod +++ b/tools/confix/go.mod @@ -17,7 +17,7 @@ require ( cosmossdk.io/api v0.7.5 // indirect cosmossdk.io/collections v0.4.0 // indirect cosmossdk.io/core v0.11.0 // indirect - cosmossdk.io/depinject v1.0.0-alpha.4 // indirect + cosmossdk.io/depinject v1.0.0 // indirect cosmossdk.io/errors v1.0.1 // indirect cosmossdk.io/log v1.3.1 // indirect cosmossdk.io/math v1.3.0 // indirect diff --git a/tools/confix/go.sum b/tools/confix/go.sum index 5737494ce2ce..bdb33226732d 100644 --- a/tools/confix/go.sum +++ b/tools/confix/go.sum @@ -6,8 +6,8 @@ cosmossdk.io/collections v0.4.0 h1:PFmwj2W8szgpD5nOd8GWH6AbYNi1f2J6akWXJ7P5t9s= cosmossdk.io/collections v0.4.0/go.mod h1:oa5lUING2dP+gdDquow+QjlF45eL1t4TJDypgGd+tv0= cosmossdk.io/core v0.11.0 h1:vtIafqUi+1ZNAE/oxLOQQ7Oek2n4S48SWLG8h/+wdbo= cosmossdk.io/core v0.11.0/go.mod h1:LaTtayWBSoacF5xNzoF8tmLhehqlA9z1SWiPuNC6X1w= -cosmossdk.io/depinject v1.0.0-alpha.4 h1:PLNp8ZYAMPTUKyG9IK2hsbciDWqna2z1Wsl98okJopc= -cosmossdk.io/depinject v1.0.0-alpha.4/go.mod h1:HeDk7IkR5ckZ3lMGs/o91AVUc7E596vMaOmslGFM3yU= +cosmossdk.io/depinject v1.0.0 h1:dQaTu6+O6askNXO06+jyeUAnF2/ssKwrrszP9t5q050= +cosmossdk.io/depinject v1.0.0/go.mod h1:zxK/h3HgHoA/eJVtiSsoaRaRA2D5U4cJ5thIG4ssbB8= cosmossdk.io/errors v1.0.1 h1:bzu+Kcr0kS/1DuPBtUFdWjzLqyUuCiyHjyJB6srBV/0= cosmossdk.io/errors v1.0.1/go.mod h1:MeelVSZThMi4bEakzhhhE/CKqVv3nOJDA25bIqRDu/U= cosmossdk.io/log v1.3.1 h1:UZx8nWIkfbbNEWusZqzAx3ZGvu54TZacWib3EzUYmGI= diff --git a/tools/cosmovisor/go.mod b/tools/cosmovisor/go.mod index aacd169fd638..21a5fea45e52 100644 --- a/tools/cosmovisor/go.mod +++ b/tools/cosmovisor/go.mod @@ -24,7 +24,7 @@ require ( cosmossdk.io/api v0.7.5 // indirect cosmossdk.io/collections v0.4.0 // indirect cosmossdk.io/core v0.11.0 // indirect - cosmossdk.io/depinject v1.0.0-alpha.4 // indirect + cosmossdk.io/depinject v1.0.0 // indirect cosmossdk.io/errors v1.0.1 // indirect cosmossdk.io/math v1.3.0 // indirect cosmossdk.io/store v1.1.0 // indirect diff --git a/tools/cosmovisor/go.sum b/tools/cosmovisor/go.sum index 713b07d3ae27..a36072f7b7b1 100644 --- a/tools/cosmovisor/go.sum +++ b/tools/cosmovisor/go.sum @@ -194,8 +194,8 @@ cosmossdk.io/collections v0.4.0 h1:PFmwj2W8szgpD5nOd8GWH6AbYNi1f2J6akWXJ7P5t9s= cosmossdk.io/collections v0.4.0/go.mod h1:oa5lUING2dP+gdDquow+QjlF45eL1t4TJDypgGd+tv0= cosmossdk.io/core v0.11.0 h1:vtIafqUi+1ZNAE/oxLOQQ7Oek2n4S48SWLG8h/+wdbo= cosmossdk.io/core v0.11.0/go.mod h1:LaTtayWBSoacF5xNzoF8tmLhehqlA9z1SWiPuNC6X1w= -cosmossdk.io/depinject v1.0.0-alpha.4 h1:PLNp8ZYAMPTUKyG9IK2hsbciDWqna2z1Wsl98okJopc= -cosmossdk.io/depinject v1.0.0-alpha.4/go.mod h1:HeDk7IkR5ckZ3lMGs/o91AVUc7E596vMaOmslGFM3yU= +cosmossdk.io/depinject v1.0.0 h1:dQaTu6+O6askNXO06+jyeUAnF2/ssKwrrszP9t5q050= +cosmossdk.io/depinject v1.0.0/go.mod h1:zxK/h3HgHoA/eJVtiSsoaRaRA2D5U4cJ5thIG4ssbB8= cosmossdk.io/errors v1.0.1 h1:bzu+Kcr0kS/1DuPBtUFdWjzLqyUuCiyHjyJB6srBV/0= cosmossdk.io/errors v1.0.1/go.mod h1:MeelVSZThMi4bEakzhhhE/CKqVv3nOJDA25bIqRDu/U= cosmossdk.io/log v1.3.1 h1:UZx8nWIkfbbNEWusZqzAx3ZGvu54TZacWib3EzUYmGI= diff --git a/tools/hubl/go.mod b/tools/hubl/go.mod index 92f960fb61b4..ac8fa90b1dc1 100644 --- a/tools/hubl/go.mod +++ b/tools/hubl/go.mod @@ -17,7 +17,7 @@ require ( require ( cosmossdk.io/collections v0.4.0 // indirect - cosmossdk.io/depinject v1.0.0-alpha.4 // indirect + cosmossdk.io/depinject v1.0.0 // indirect cosmossdk.io/log v1.3.1 // indirect cosmossdk.io/math v1.3.0 // indirect cosmossdk.io/store v1.1.0 // indirect diff --git a/tools/hubl/go.sum b/tools/hubl/go.sum index 0cc13874c939..954afa4073f5 100644 --- a/tools/hubl/go.sum +++ b/tools/hubl/go.sum @@ -8,8 +8,8 @@ cosmossdk.io/collections v0.4.0 h1:PFmwj2W8szgpD5nOd8GWH6AbYNi1f2J6akWXJ7P5t9s= cosmossdk.io/collections v0.4.0/go.mod h1:oa5lUING2dP+gdDquow+QjlF45eL1t4TJDypgGd+tv0= cosmossdk.io/core v0.11.0 h1:vtIafqUi+1ZNAE/oxLOQQ7Oek2n4S48SWLG8h/+wdbo= cosmossdk.io/core v0.11.0/go.mod h1:LaTtayWBSoacF5xNzoF8tmLhehqlA9z1SWiPuNC6X1w= -cosmossdk.io/depinject v1.0.0-alpha.4 h1:PLNp8ZYAMPTUKyG9IK2hsbciDWqna2z1Wsl98okJopc= -cosmossdk.io/depinject v1.0.0-alpha.4/go.mod h1:HeDk7IkR5ckZ3lMGs/o91AVUc7E596vMaOmslGFM3yU= +cosmossdk.io/depinject v1.0.0 h1:dQaTu6+O6askNXO06+jyeUAnF2/ssKwrrszP9t5q050= +cosmossdk.io/depinject v1.0.0/go.mod h1:zxK/h3HgHoA/eJVtiSsoaRaRA2D5U4cJ5thIG4ssbB8= cosmossdk.io/errors v1.0.1 h1:bzu+Kcr0kS/1DuPBtUFdWjzLqyUuCiyHjyJB6srBV/0= cosmossdk.io/errors v1.0.1/go.mod h1:MeelVSZThMi4bEakzhhhE/CKqVv3nOJDA25bIqRDu/U= cosmossdk.io/log v1.3.1 h1:UZx8nWIkfbbNEWusZqzAx3ZGvu54TZacWib3EzUYmGI= diff --git a/x/accounts/defaults/lockup/go.mod b/x/accounts/defaults/lockup/go.mod index d778d3689424..daa4b58f5325 100644 --- a/x/accounts/defaults/lockup/go.mod +++ b/x/accounts/defaults/lockup/go.mod @@ -18,7 +18,7 @@ require cosmossdk.io/x/consensus v0.0.0-00010101000000-000000000000 // indirect require ( buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.34.2-20240701160653-fedbb9acfd2f.2 // indirect cosmossdk.io/core/testing v0.0.0-00010101000000-000000000000 // indirect - cosmossdk.io/depinject v1.0.0-alpha.4 // indirect + cosmossdk.io/depinject v1.0.0 // indirect cosmossdk.io/schema v0.1.1 // indirect github.com/cometbft/cometbft/api v1.0.0-rc.1 // indirect github.com/cosmos/crypto v0.1.2 // indirect @@ -176,7 +176,6 @@ replace ( cosmossdk.io/collections => ../../../../collections // TODO tag new collections ASAP cosmossdk.io/core => ../../../../core cosmossdk.io/core/testing => ../../../../core/testing - cosmossdk.io/depinject => ../../../../depinject cosmossdk.io/log => ../../../../log cosmossdk.io/x/accounts => ../../. cosmossdk.io/x/auth => ../../../auth diff --git a/x/accounts/defaults/lockup/go.sum b/x/accounts/defaults/lockup/go.sum index 6a551cec1660..7c088816d9a3 100644 --- a/x/accounts/defaults/lockup/go.sum +++ b/x/accounts/defaults/lockup/go.sum @@ -4,6 +4,8 @@ buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.34.2-20240130113600-88e buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.34.2-20240130113600-88ef6483f90f.2/go.mod h1:HqcXMSa5qnNuakaMUo+hWhF51mKbcrZxGl9Vp5EeJXc= cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= +cosmossdk.io/depinject v1.0.0 h1:dQaTu6+O6askNXO06+jyeUAnF2/ssKwrrszP9t5q050= +cosmossdk.io/depinject v1.0.0/go.mod h1:zxK/h3HgHoA/eJVtiSsoaRaRA2D5U4cJ5thIG4ssbB8= cosmossdk.io/errors v1.0.1 h1:bzu+Kcr0kS/1DuPBtUFdWjzLqyUuCiyHjyJB6srBV/0= cosmossdk.io/errors v1.0.1/go.mod h1:MeelVSZThMi4bEakzhhhE/CKqVv3nOJDA25bIqRDu/U= cosmossdk.io/math v1.3.0 h1:RC+jryuKeytIiictDslBP9i1fhkVm6ZDmZEoNP316zE= diff --git a/x/accounts/defaults/multisig/go.mod b/x/accounts/defaults/multisig/go.mod index e916c454b755..4a7254390618 100644 --- a/x/accounts/defaults/multisig/go.mod +++ b/x/accounts/defaults/multisig/go.mod @@ -20,7 +20,7 @@ require ( buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.34.2-20240130113600-88ef6483f90f.2 // indirect cosmossdk.io/api v0.7.5 // indirect cosmossdk.io/core/testing v0.0.0-00010101000000-000000000000 // indirect - cosmossdk.io/depinject v1.0.0-alpha.4 // indirect + cosmossdk.io/depinject v1.0.0 // indirect cosmossdk.io/errors v1.0.1 // indirect cosmossdk.io/log v1.3.1 // indirect cosmossdk.io/schema v0.1.1 // indirect @@ -177,7 +177,6 @@ replace ( cosmossdk.io/collections => ../../../../collections // TODO tag new collections ASAP cosmossdk.io/core => ../../../../core cosmossdk.io/core/testing => ../../../../core/testing - cosmossdk.io/depinject => ../../../../depinject cosmossdk.io/log => ../../../../log cosmossdk.io/x/accounts => ../../. cosmossdk.io/x/auth => ../../../auth @@ -188,4 +187,5 @@ replace ( cosmossdk.io/x/protocolpool => ../../../protocolpool cosmossdk.io/x/slashing => ../../../slashing cosmossdk.io/x/staking => ../../../staking + cosmossdk.io/x/tx => ../../../tx ) diff --git a/x/accounts/defaults/multisig/go.sum b/x/accounts/defaults/multisig/go.sum index db6a096219de..1516cc35ec12 100644 --- a/x/accounts/defaults/multisig/go.sum +++ b/x/accounts/defaults/multisig/go.sum @@ -4,6 +4,8 @@ buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.34.2-20240130113600-88e buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.34.2-20240130113600-88ef6483f90f.2/go.mod h1:HqcXMSa5qnNuakaMUo+hWhF51mKbcrZxGl9Vp5EeJXc= cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= +cosmossdk.io/depinject v1.0.0 h1:dQaTu6+O6askNXO06+jyeUAnF2/ssKwrrszP9t5q050= +cosmossdk.io/depinject v1.0.0/go.mod h1:zxK/h3HgHoA/eJVtiSsoaRaRA2D5U4cJ5thIG4ssbB8= cosmossdk.io/errors v1.0.1 h1:bzu+Kcr0kS/1DuPBtUFdWjzLqyUuCiyHjyJB6srBV/0= cosmossdk.io/errors v1.0.1/go.mod h1:MeelVSZThMi4bEakzhhhE/CKqVv3nOJDA25bIqRDu/U= cosmossdk.io/math v1.3.0 h1:RC+jryuKeytIiictDslBP9i1fhkVm6ZDmZEoNP316zE= @@ -12,8 +14,6 @@ cosmossdk.io/schema v0.1.1 h1:I0M6pgI7R10nq+/HCQfbO6BsGBZA8sQy+duR1Y3aKcA= cosmossdk.io/schema v0.1.1/go.mod h1:RDAhxIeNB4bYqAlF4NBJwRrgtnciMcyyg0DOKnhNZQQ= cosmossdk.io/store v1.1.1-0.20240418092142-896cdf1971bc h1:R9O9d75e0qZYUsVV0zzi+D7cNLnX2JrUOQNoIPaF0Bg= cosmossdk.io/store v1.1.1-0.20240418092142-896cdf1971bc/go.mod h1:amTTatOUV3u1PsKmNb87z6/galCxrRbz9kRdJkL0DyU= -cosmossdk.io/x/tx v0.13.3 h1:Ha4mNaHmxBc6RMun9aKuqul8yHiL78EKJQ8g23Zf73g= -cosmossdk.io/x/tx v0.13.3/go.mod h1:I8xaHv0rhUdIvIdptKIqzYy27+n2+zBVaxO6fscFhys= filippo.io/edwards25519 v1.1.0 h1:FNf4tywRC1HmFuKW5xopWpigGjJKiJSV0Cqo0cJWDaA= filippo.io/edwards25519 v1.1.0/go.mod h1:BxyFTGdWcka3PhytdK4V28tE5sGfRvvvRV7EaN4VDT4= github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 h1:/vQbFIOMbk2FiG/kXiLl8BRyzTWDw7gX/Hz7Dd5eDMs= diff --git a/x/accounts/go.mod b/x/accounts/go.mod index 0a2b6d9a7666..30ddbf7df8f7 100644 --- a/x/accounts/go.mod +++ b/x/accounts/go.mod @@ -7,7 +7,7 @@ require ( cosmossdk.io/collections v0.4.0 cosmossdk.io/core v0.12.1-0.20231114100755-569e3ff6a0d7 cosmossdk.io/core/testing v0.0.0-00010101000000-000000000000 - cosmossdk.io/depinject v1.0.0-alpha.4 + cosmossdk.io/depinject v1.0.0 cosmossdk.io/x/accounts/defaults/multisig v0.0.0-00010101000000-000000000000 cosmossdk.io/x/bank v0.0.0-20240226161501-23359a0b6d91 cosmossdk.io/x/tx v0.13.3 @@ -184,7 +184,6 @@ replace ( cosmossdk.io/collections => ../../collections cosmossdk.io/core => ../../core cosmossdk.io/core/testing => ../../core/testing - cosmossdk.io/depinject => ../../depinject cosmossdk.io/log => ../../log cosmossdk.io/x/accounts/defaults/multisig => ./defaults/multisig cosmossdk.io/x/auth => ../auth diff --git a/x/accounts/go.sum b/x/accounts/go.sum index 99a16b5789f2..35a069913927 100644 --- a/x/accounts/go.sum +++ b/x/accounts/go.sum @@ -4,6 +4,8 @@ buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.34.2-20240130113600-88e buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.34.2-20240130113600-88ef6483f90f.2/go.mod h1:HqcXMSa5qnNuakaMUo+hWhF51mKbcrZxGl9Vp5EeJXc= cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= +cosmossdk.io/depinject v1.0.0 h1:dQaTu6+O6askNXO06+jyeUAnF2/ssKwrrszP9t5q050= +cosmossdk.io/depinject v1.0.0/go.mod h1:zxK/h3HgHoA/eJVtiSsoaRaRA2D5U4cJ5thIG4ssbB8= cosmossdk.io/errors v1.0.1 h1:bzu+Kcr0kS/1DuPBtUFdWjzLqyUuCiyHjyJB6srBV/0= cosmossdk.io/errors v1.0.1/go.mod h1:MeelVSZThMi4bEakzhhhE/CKqVv3nOJDA25bIqRDu/U= cosmossdk.io/math v1.3.0 h1:RC+jryuKeytIiictDslBP9i1fhkVm6ZDmZEoNP316zE= diff --git a/x/auth/go.mod b/x/auth/go.mod index 36809cc0c27e..a22cb0b4b0d7 100644 --- a/x/auth/go.mod +++ b/x/auth/go.mod @@ -7,7 +7,7 @@ require ( cosmossdk.io/collections v0.4.0 cosmossdk.io/core v0.12.1-0.20231114100755-569e3ff6a0d7 cosmossdk.io/core/testing v0.0.0-00010101000000-000000000000 - cosmossdk.io/depinject v1.0.0-alpha.4 + cosmossdk.io/depinject v1.0.0 cosmossdk.io/errors v1.0.1 cosmossdk.io/math v1.3.0 cosmossdk.io/store v1.1.1-0.20240418092142-896cdf1971bc @@ -177,7 +177,6 @@ replace ( cosmossdk.io/collections => ../../collections cosmossdk.io/core => ../../core cosmossdk.io/core/testing => ../../core/testing - cosmossdk.io/depinject => ../../depinject cosmossdk.io/log => ../../log cosmossdk.io/x/accounts => ../accounts cosmossdk.io/x/bank => ../bank diff --git a/x/auth/go.sum b/x/auth/go.sum index 7c6b086874ef..4879cfa34550 100644 --- a/x/auth/go.sum +++ b/x/auth/go.sum @@ -4,6 +4,8 @@ buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.34.2-20240130113600-88e buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.34.2-20240130113600-88ef6483f90f.2/go.mod h1:HqcXMSa5qnNuakaMUo+hWhF51mKbcrZxGl9Vp5EeJXc= cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= +cosmossdk.io/depinject v1.0.0 h1:dQaTu6+O6askNXO06+jyeUAnF2/ssKwrrszP9t5q050= +cosmossdk.io/depinject v1.0.0/go.mod h1:zxK/h3HgHoA/eJVtiSsoaRaRA2D5U4cJ5thIG4ssbB8= cosmossdk.io/errors v1.0.1 h1:bzu+Kcr0kS/1DuPBtUFdWjzLqyUuCiyHjyJB6srBV/0= cosmossdk.io/errors v1.0.1/go.mod h1:MeelVSZThMi4bEakzhhhE/CKqVv3nOJDA25bIqRDu/U= cosmossdk.io/math v1.3.0 h1:RC+jryuKeytIiictDslBP9i1fhkVm6ZDmZEoNP316zE= diff --git a/x/authz/go.mod b/x/authz/go.mod index 8b97249bdc4d..a262c055d6fc 100644 --- a/x/authz/go.mod +++ b/x/authz/go.mod @@ -5,7 +5,7 @@ go 1.22.2 require ( cosmossdk.io/api v0.7.5 cosmossdk.io/core v0.12.1-0.20231114100755-569e3ff6a0d7 - cosmossdk.io/depinject v1.0.0-alpha.4 + cosmossdk.io/depinject v1.0.0 cosmossdk.io/errors v1.0.1 cosmossdk.io/math v1.3.0 cosmossdk.io/store v1.1.1-0.20240418092142-896cdf1971bc @@ -182,9 +182,7 @@ replace ( cosmossdk.io/collections => ../../collections cosmossdk.io/core => ../../core cosmossdk.io/core/testing => ../../core/testing - cosmossdk.io/depinject => ../../depinject cosmossdk.io/log => ../../log - cosmossdk.io/logger => ../../logger cosmossdk.io/store => ../../store cosmossdk.io/x/accounts => ../accounts cosmossdk.io/x/auth => ../auth diff --git a/x/authz/go.sum b/x/authz/go.sum index 70ef03925e0a..c89bb859d759 100644 --- a/x/authz/go.sum +++ b/x/authz/go.sum @@ -4,6 +4,8 @@ buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.34.2-20240130113600-88e buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.34.2-20240130113600-88ef6483f90f.2/go.mod h1:HqcXMSa5qnNuakaMUo+hWhF51mKbcrZxGl9Vp5EeJXc= cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= +cosmossdk.io/depinject v1.0.0 h1:dQaTu6+O6askNXO06+jyeUAnF2/ssKwrrszP9t5q050= +cosmossdk.io/depinject v1.0.0/go.mod h1:zxK/h3HgHoA/eJVtiSsoaRaRA2D5U4cJ5thIG4ssbB8= cosmossdk.io/errors v1.0.1 h1:bzu+Kcr0kS/1DuPBtUFdWjzLqyUuCiyHjyJB6srBV/0= cosmossdk.io/errors v1.0.1/go.mod h1:MeelVSZThMi4bEakzhhhE/CKqVv3nOJDA25bIqRDu/U= cosmossdk.io/math v1.3.0 h1:RC+jryuKeytIiictDslBP9i1fhkVm6ZDmZEoNP316zE= diff --git a/x/bank/go.mod b/x/bank/go.mod index a55c27bf07a7..480d7c39ba4e 100644 --- a/x/bank/go.mod +++ b/x/bank/go.mod @@ -6,7 +6,7 @@ require ( cosmossdk.io/api v0.7.5 cosmossdk.io/collections v0.4.0 cosmossdk.io/core v0.12.1-0.20231114100755-569e3ff6a0d7 - cosmossdk.io/depinject v1.0.0-alpha.4 + cosmossdk.io/depinject v1.0.0 cosmossdk.io/errors v1.0.1 cosmossdk.io/log v1.3.1 // indirect cosmossdk.io/math v1.3.0 @@ -181,7 +181,6 @@ replace ( cosmossdk.io/collections => ../../collections cosmossdk.io/core => ../../core cosmossdk.io/core/testing => ../../core/testing - cosmossdk.io/depinject => ../../depinject cosmossdk.io/log => ../../log cosmossdk.io/x/accounts => ../accounts cosmossdk.io/x/auth => ../auth diff --git a/x/bank/go.sum b/x/bank/go.sum index 7c6b086874ef..4879cfa34550 100644 --- a/x/bank/go.sum +++ b/x/bank/go.sum @@ -4,6 +4,8 @@ buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.34.2-20240130113600-88e buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.34.2-20240130113600-88ef6483f90f.2/go.mod h1:HqcXMSa5qnNuakaMUo+hWhF51mKbcrZxGl9Vp5EeJXc= cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= +cosmossdk.io/depinject v1.0.0 h1:dQaTu6+O6askNXO06+jyeUAnF2/ssKwrrszP9t5q050= +cosmossdk.io/depinject v1.0.0/go.mod h1:zxK/h3HgHoA/eJVtiSsoaRaRA2D5U4cJ5thIG4ssbB8= cosmossdk.io/errors v1.0.1 h1:bzu+Kcr0kS/1DuPBtUFdWjzLqyUuCiyHjyJB6srBV/0= cosmossdk.io/errors v1.0.1/go.mod h1:MeelVSZThMi4bEakzhhhE/CKqVv3nOJDA25bIqRDu/U= cosmossdk.io/math v1.3.0 h1:RC+jryuKeytIiictDslBP9i1fhkVm6ZDmZEoNP316zE= diff --git a/x/circuit/go.mod b/x/circuit/go.mod index 2d8a15a32a9b..68b9e5ca1ff6 100644 --- a/x/circuit/go.mod +++ b/x/circuit/go.mod @@ -7,7 +7,7 @@ require ( cosmossdk.io/collections v0.4.0 cosmossdk.io/core v0.12.1-0.20231114100755-569e3ff6a0d7 cosmossdk.io/core/testing v0.0.0-00010101000000-000000000000 - cosmossdk.io/depinject v1.0.0-alpha.4 + cosmossdk.io/depinject v1.0.0 cosmossdk.io/errors v1.0.1 cosmossdk.io/store v1.1.1-0.20240418092142-896cdf1971bc cosmossdk.io/x/auth v0.0.0-00010101000000-000000000000 @@ -177,7 +177,6 @@ replace ( cosmossdk.io/api => ../../api cosmossdk.io/core => ../../core cosmossdk.io/core/testing => ../../core/testing - cosmossdk.io/depinject => ../../depinject cosmossdk.io/log => ../../log cosmossdk.io/x/accounts => ../accounts cosmossdk.io/x/auth => ../auth diff --git a/x/circuit/go.sum b/x/circuit/go.sum index c2479081cac7..08da56c9d15e 100644 --- a/x/circuit/go.sum +++ b/x/circuit/go.sum @@ -6,6 +6,8 @@ cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMT cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= cosmossdk.io/collections v0.4.0 h1:PFmwj2W8szgpD5nOd8GWH6AbYNi1f2J6akWXJ7P5t9s= cosmossdk.io/collections v0.4.0/go.mod h1:oa5lUING2dP+gdDquow+QjlF45eL1t4TJDypgGd+tv0= +cosmossdk.io/depinject v1.0.0 h1:dQaTu6+O6askNXO06+jyeUAnF2/ssKwrrszP9t5q050= +cosmossdk.io/depinject v1.0.0/go.mod h1:zxK/h3HgHoA/eJVtiSsoaRaRA2D5U4cJ5thIG4ssbB8= cosmossdk.io/errors v1.0.1 h1:bzu+Kcr0kS/1DuPBtUFdWjzLqyUuCiyHjyJB6srBV/0= cosmossdk.io/errors v1.0.1/go.mod h1:MeelVSZThMi4bEakzhhhE/CKqVv3nOJDA25bIqRDu/U= cosmossdk.io/math v1.3.0 h1:RC+jryuKeytIiictDslBP9i1fhkVm6ZDmZEoNP316zE= diff --git a/x/consensus/go.mod b/x/consensus/go.mod index cc73bce6d289..3ca3a4af640b 100644 --- a/x/consensus/go.mod +++ b/x/consensus/go.mod @@ -7,7 +7,7 @@ require ( cosmossdk.io/collections v0.4.0 cosmossdk.io/core v0.12.1-0.20231114100755-569e3ff6a0d7 cosmossdk.io/core/testing v0.0.0-00010101000000-000000000000 - cosmossdk.io/depinject v1.0.0-alpha.4 + cosmossdk.io/depinject v1.0.0 cosmossdk.io/store v1.1.1-0.20240418092142-896cdf1971bc github.com/cometbft/cometbft v1.0.0-rc1 github.com/cometbft/cometbft/api v1.0.0-rc.1 @@ -174,7 +174,6 @@ replace ( cosmossdk.io/api => ../../api cosmossdk.io/core => ../../core cosmossdk.io/core/testing => ../../core/testing - cosmossdk.io/depinject => ../../depinject cosmossdk.io/log => ../../log cosmossdk.io/x/accounts => ../accounts cosmossdk.io/x/auth => ../auth diff --git a/x/consensus/go.sum b/x/consensus/go.sum index 2aa9efc32a9b..496f78619dc0 100644 --- a/x/consensus/go.sum +++ b/x/consensus/go.sum @@ -6,6 +6,8 @@ cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMT cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= cosmossdk.io/collections v0.4.0 h1:PFmwj2W8szgpD5nOd8GWH6AbYNi1f2J6akWXJ7P5t9s= cosmossdk.io/collections v0.4.0/go.mod h1:oa5lUING2dP+gdDquow+QjlF45eL1t4TJDypgGd+tv0= +cosmossdk.io/depinject v1.0.0 h1:dQaTu6+O6askNXO06+jyeUAnF2/ssKwrrszP9t5q050= +cosmossdk.io/depinject v1.0.0/go.mod h1:zxK/h3HgHoA/eJVtiSsoaRaRA2D5U4cJ5thIG4ssbB8= cosmossdk.io/errors v1.0.1 h1:bzu+Kcr0kS/1DuPBtUFdWjzLqyUuCiyHjyJB6srBV/0= cosmossdk.io/errors v1.0.1/go.mod h1:MeelVSZThMi4bEakzhhhE/CKqVv3nOJDA25bIqRDu/U= cosmossdk.io/math v1.3.0 h1:RC+jryuKeytIiictDslBP9i1fhkVm6ZDmZEoNP316zE= diff --git a/x/distribution/go.mod b/x/distribution/go.mod index b812981659ac..5773e7fb3c21 100644 --- a/x/distribution/go.mod +++ b/x/distribution/go.mod @@ -7,7 +7,7 @@ require ( cosmossdk.io/collections v0.4.0 cosmossdk.io/core v0.12.1-0.20231114100755-569e3ff6a0d7 cosmossdk.io/core/testing v0.0.0-00010101000000-000000000000 - cosmossdk.io/depinject v1.0.0-alpha.4 + cosmossdk.io/depinject v1.0.0 cosmossdk.io/errors v1.0.1 cosmossdk.io/log v1.3.1 cosmossdk.io/math v1.3.0 @@ -182,7 +182,6 @@ replace ( cosmossdk.io/collections => ../../collections cosmossdk.io/core => ../../core cosmossdk.io/core/testing => ../../core/testing - cosmossdk.io/depinject => ../../depinject cosmossdk.io/log => ../../log cosmossdk.io/x/accounts => ../accounts cosmossdk.io/x/auth => ../auth diff --git a/x/distribution/go.sum b/x/distribution/go.sum index 4aa0abf8728a..58a04eb3afea 100644 --- a/x/distribution/go.sum +++ b/x/distribution/go.sum @@ -4,6 +4,8 @@ buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.34.2-20240130113600-88e buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.34.2-20240130113600-88ef6483f90f.2/go.mod h1:HqcXMSa5qnNuakaMUo+hWhF51mKbcrZxGl9Vp5EeJXc= cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= +cosmossdk.io/depinject v1.0.0 h1:dQaTu6+O6askNXO06+jyeUAnF2/ssKwrrszP9t5q050= +cosmossdk.io/depinject v1.0.0/go.mod h1:zxK/h3HgHoA/eJVtiSsoaRaRA2D5U4cJ5thIG4ssbB8= cosmossdk.io/errors v1.0.1 h1:bzu+Kcr0kS/1DuPBtUFdWjzLqyUuCiyHjyJB6srBV/0= cosmossdk.io/errors v1.0.1/go.mod h1:MeelVSZThMi4bEakzhhhE/CKqVv3nOJDA25bIqRDu/U= cosmossdk.io/math v1.3.0 h1:RC+jryuKeytIiictDslBP9i1fhkVm6ZDmZEoNP316zE= diff --git a/x/epochs/go.mod b/x/epochs/go.mod index 6842a566fd9a..4642488a952e 100644 --- a/x/epochs/go.mod +++ b/x/epochs/go.mod @@ -7,7 +7,7 @@ require ( cosmossdk.io/collections v0.4.0 cosmossdk.io/core v0.12.1-0.20231114100755-569e3ff6a0d7 cosmossdk.io/core/testing v0.0.0-00010101000000-000000000000 - cosmossdk.io/depinject v1.0.0-alpha.4 + cosmossdk.io/depinject v1.0.0 cosmossdk.io/errors v1.0.1 cosmossdk.io/store v1.1.1-0.20240418092142-896cdf1971bc github.com/cosmos/cosmos-proto v1.0.0-beta.5 @@ -179,7 +179,6 @@ replace ( cosmossdk.io/api => ../../api cosmossdk.io/core => ../../core cosmossdk.io/core/testing => ../../core/testing - cosmossdk.io/depinject => ../../depinject cosmossdk.io/log => ../../log cosmossdk.io/x/accounts => ../accounts cosmossdk.io/x/auth => ../auth diff --git a/x/epochs/go.sum b/x/epochs/go.sum index 2aa9efc32a9b..496f78619dc0 100644 --- a/x/epochs/go.sum +++ b/x/epochs/go.sum @@ -6,6 +6,8 @@ cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMT cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= cosmossdk.io/collections v0.4.0 h1:PFmwj2W8szgpD5nOd8GWH6AbYNi1f2J6akWXJ7P5t9s= cosmossdk.io/collections v0.4.0/go.mod h1:oa5lUING2dP+gdDquow+QjlF45eL1t4TJDypgGd+tv0= +cosmossdk.io/depinject v1.0.0 h1:dQaTu6+O6askNXO06+jyeUAnF2/ssKwrrszP9t5q050= +cosmossdk.io/depinject v1.0.0/go.mod h1:zxK/h3HgHoA/eJVtiSsoaRaRA2D5U4cJ5thIG4ssbB8= cosmossdk.io/errors v1.0.1 h1:bzu+Kcr0kS/1DuPBtUFdWjzLqyUuCiyHjyJB6srBV/0= cosmossdk.io/errors v1.0.1/go.mod h1:MeelVSZThMi4bEakzhhhE/CKqVv3nOJDA25bIqRDu/U= cosmossdk.io/math v1.3.0 h1:RC+jryuKeytIiictDslBP9i1fhkVm6ZDmZEoNP316zE= diff --git a/x/evidence/go.mod b/x/evidence/go.mod index 4c20a6686878..680c72d2d6ce 100644 --- a/x/evidence/go.mod +++ b/x/evidence/go.mod @@ -7,7 +7,7 @@ require ( cosmossdk.io/collections v0.4.0 cosmossdk.io/core v0.12.1-0.20231114100755-569e3ff6a0d7 cosmossdk.io/core/testing v0.0.0-00010101000000-000000000000 - cosmossdk.io/depinject v1.0.0-alpha.4 + cosmossdk.io/depinject v1.0.0 cosmossdk.io/errors v1.0.1 cosmossdk.io/math v1.3.0 cosmossdk.io/store v1.1.1-0.20240418092142-896cdf1971bc @@ -177,7 +177,6 @@ replace ( cosmossdk.io/api => ../../api cosmossdk.io/core => ../../core cosmossdk.io/core/testing => ../../core/testing - cosmossdk.io/depinject => ../../depinject cosmossdk.io/log => ../../log cosmossdk.io/x/accounts => ../accounts cosmossdk.io/x/auth => ../auth diff --git a/x/evidence/go.sum b/x/evidence/go.sum index c2479081cac7..08da56c9d15e 100644 --- a/x/evidence/go.sum +++ b/x/evidence/go.sum @@ -6,6 +6,8 @@ cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMT cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= cosmossdk.io/collections v0.4.0 h1:PFmwj2W8szgpD5nOd8GWH6AbYNi1f2J6akWXJ7P5t9s= cosmossdk.io/collections v0.4.0/go.mod h1:oa5lUING2dP+gdDquow+QjlF45eL1t4TJDypgGd+tv0= +cosmossdk.io/depinject v1.0.0 h1:dQaTu6+O6askNXO06+jyeUAnF2/ssKwrrszP9t5q050= +cosmossdk.io/depinject v1.0.0/go.mod h1:zxK/h3HgHoA/eJVtiSsoaRaRA2D5U4cJ5thIG4ssbB8= cosmossdk.io/errors v1.0.1 h1:bzu+Kcr0kS/1DuPBtUFdWjzLqyUuCiyHjyJB6srBV/0= cosmossdk.io/errors v1.0.1/go.mod h1:MeelVSZThMi4bEakzhhhE/CKqVv3nOJDA25bIqRDu/U= cosmossdk.io/math v1.3.0 h1:RC+jryuKeytIiictDslBP9i1fhkVm6ZDmZEoNP316zE= diff --git a/x/feegrant/go.mod b/x/feegrant/go.mod index a1ab606ae9f1..87acb3ccf648 100644 --- a/x/feegrant/go.mod +++ b/x/feegrant/go.mod @@ -7,7 +7,7 @@ require ( cosmossdk.io/collections v0.4.0 cosmossdk.io/core v0.12.1-0.20231114100755-569e3ff6a0d7 cosmossdk.io/core/testing v0.0.0-00010101000000-000000000000 - cosmossdk.io/depinject v1.0.0-alpha.4 + cosmossdk.io/depinject v1.0.0 cosmossdk.io/errors v1.0.1 cosmossdk.io/math v1.3.0 cosmossdk.io/store v1.1.1-0.20240418092142-896cdf1971bc @@ -32,6 +32,7 @@ require ( buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.34.2-20240701160653-fedbb9acfd2f.2 // indirect buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.34.2-20240130113600-88ef6483f90f.2 // indirect cosmossdk.io/log v1.3.1 // indirect + cosmossdk.io/schema v0.1.1 // indirect cosmossdk.io/x/auth v0.0.0-00010101000000-000000000000 cosmossdk.io/x/consensus v0.0.0-00010101000000-000000000000 // indirect cosmossdk.io/x/protocolpool v0.0.0-20230925135524-a1bc045b3190 // indirect @@ -121,6 +122,7 @@ require ( github.com/mitchellh/go-testing-interface v1.14.1 // indirect github.com/mitchellh/mapstructure v1.5.0 // indirect github.com/mtibben/percent v0.2.1 // indirect + github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect github.com/oasisprotocol/curve25519-voi v0.0.0-20230904125328-1f23a7beb09a // indirect github.com/oklog/run v1.1.0 // indirect github.com/pelletier/go-toml/v2 v2.2.2 // indirect @@ -172,11 +174,6 @@ require ( sigs.k8s.io/yaml v1.4.0 // indirect ) -require ( - cosmossdk.io/schema v0.1.1 // indirect - github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect -) - replace github.com/cosmos/cosmos-sdk => ../../. // TODO remove post spinning out all modules @@ -185,7 +182,6 @@ replace ( cosmossdk.io/collections => ../../collections cosmossdk.io/core => ../../core cosmossdk.io/core/testing => ../../core/testing - cosmossdk.io/depinject => ../../depinject cosmossdk.io/log => ../../log cosmossdk.io/x/accounts => ../accounts cosmossdk.io/x/auth => ../auth diff --git a/x/feegrant/go.sum b/x/feegrant/go.sum index c0d696396264..5f0cfa9d7fd6 100644 --- a/x/feegrant/go.sum +++ b/x/feegrant/go.sum @@ -4,6 +4,8 @@ buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.34.2-20240130113600-88e buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.34.2-20240130113600-88ef6483f90f.2/go.mod h1:HqcXMSa5qnNuakaMUo+hWhF51mKbcrZxGl9Vp5EeJXc= cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= +cosmossdk.io/depinject v1.0.0 h1:dQaTu6+O6askNXO06+jyeUAnF2/ssKwrrszP9t5q050= +cosmossdk.io/depinject v1.0.0/go.mod h1:zxK/h3HgHoA/eJVtiSsoaRaRA2D5U4cJ5thIG4ssbB8= cosmossdk.io/errors v1.0.1 h1:bzu+Kcr0kS/1DuPBtUFdWjzLqyUuCiyHjyJB6srBV/0= cosmossdk.io/errors v1.0.1/go.mod h1:MeelVSZThMi4bEakzhhhE/CKqVv3nOJDA25bIqRDu/U= cosmossdk.io/math v1.3.0 h1:RC+jryuKeytIiictDslBP9i1fhkVm6ZDmZEoNP316zE= diff --git a/x/gov/go.mod b/x/gov/go.mod index 52ce9816d89e..c15954f2056a 100644 --- a/x/gov/go.mod +++ b/x/gov/go.mod @@ -7,7 +7,7 @@ require ( cosmossdk.io/collections v0.4.0 cosmossdk.io/core v0.12.1-0.20231114100755-569e3ff6a0d7 cosmossdk.io/core/testing v0.0.0-00010101000000-000000000000 - cosmossdk.io/depinject v1.0.0-alpha.4 + cosmossdk.io/depinject v1.0.0 cosmossdk.io/errors v1.0.1 cosmossdk.io/log v1.3.1 // indirect cosmossdk.io/math v1.3.0 @@ -38,6 +38,7 @@ require ( require ( buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.34.2-20240701160653-fedbb9acfd2f.2 // indirect buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.34.2-20240130113600-88ef6483f90f.2 // indirect + cosmossdk.io/schema v0.1.1 // indirect cosmossdk.io/x/consensus v0.0.0-00010101000000-000000000000 // indirect cosmossdk.io/x/tx v0.13.3 // indirect filippo.io/edwards25519 v1.1.0 // indirect @@ -172,8 +173,6 @@ require ( sigs.k8s.io/yaml v1.4.0 // indirect ) -require cosmossdk.io/schema v0.1.1 // indirect - replace github.com/cosmos/cosmos-sdk => ../../. // TODO remove post spinning out all modules @@ -182,7 +181,6 @@ replace ( cosmossdk.io/collections => ../../collections cosmossdk.io/core => ../../core cosmossdk.io/core/testing => ../../core/testing - cosmossdk.io/depinject => ../../depinject cosmossdk.io/log => ../../log cosmossdk.io/x/accounts => ../accounts cosmossdk.io/x/auth => ../auth diff --git a/x/gov/go.sum b/x/gov/go.sum index 8b0e673b096e..94340b7551c8 100644 --- a/x/gov/go.sum +++ b/x/gov/go.sum @@ -4,6 +4,8 @@ buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.34.2-20240130113600-88e buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.34.2-20240130113600-88ef6483f90f.2/go.mod h1:HqcXMSa5qnNuakaMUo+hWhF51mKbcrZxGl9Vp5EeJXc= cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= +cosmossdk.io/depinject v1.0.0 h1:dQaTu6+O6askNXO06+jyeUAnF2/ssKwrrszP9t5q050= +cosmossdk.io/depinject v1.0.0/go.mod h1:zxK/h3HgHoA/eJVtiSsoaRaRA2D5U4cJ5thIG4ssbB8= cosmossdk.io/errors v1.0.1 h1:bzu+Kcr0kS/1DuPBtUFdWjzLqyUuCiyHjyJB6srBV/0= cosmossdk.io/errors v1.0.1/go.mod h1:MeelVSZThMi4bEakzhhhE/CKqVv3nOJDA25bIqRDu/U= cosmossdk.io/math v1.3.0 h1:RC+jryuKeytIiictDslBP9i1fhkVm6ZDmZEoNP316zE= diff --git a/x/group/go.mod b/x/group/go.mod index 80c70d3d79c5..e0b54245f1d7 100644 --- a/x/group/go.mod +++ b/x/group/go.mod @@ -5,7 +5,7 @@ go 1.22.2 require ( cosmossdk.io/api v0.7.5 cosmossdk.io/core v0.12.1-0.20231114100755-569e3ff6a0d7 - cosmossdk.io/depinject v1.0.0-alpha.4 + cosmossdk.io/depinject v1.0.0 cosmossdk.io/errors v1.0.1 cosmossdk.io/log v1.3.1 cosmossdk.io/math v1.3.0 @@ -188,7 +188,6 @@ replace ( cosmossdk.io/collections => ../../collections cosmossdk.io/core => ../../core cosmossdk.io/core/testing => ../../core/testing - cosmossdk.io/depinject => ../../depinject cosmossdk.io/log => ../../log cosmossdk.io/x/accounts => ../accounts cosmossdk.io/x/accounts/defaults/multisig => ../accounts/defaults/multisig diff --git a/x/group/go.sum b/x/group/go.sum index e3dc6325d997..64812e201047 100644 --- a/x/group/go.sum +++ b/x/group/go.sum @@ -4,6 +4,8 @@ buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.34.2-20240130113600-88e buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.34.2-20240130113600-88ef6483f90f.2/go.mod h1:HqcXMSa5qnNuakaMUo+hWhF51mKbcrZxGl9Vp5EeJXc= cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= +cosmossdk.io/depinject v1.0.0 h1:dQaTu6+O6askNXO06+jyeUAnF2/ssKwrrszP9t5q050= +cosmossdk.io/depinject v1.0.0/go.mod h1:zxK/h3HgHoA/eJVtiSsoaRaRA2D5U4cJ5thIG4ssbB8= cosmossdk.io/errors v1.0.1 h1:bzu+Kcr0kS/1DuPBtUFdWjzLqyUuCiyHjyJB6srBV/0= cosmossdk.io/errors v1.0.1/go.mod h1:MeelVSZThMi4bEakzhhhE/CKqVv3nOJDA25bIqRDu/U= cosmossdk.io/math v1.3.0 h1:RC+jryuKeytIiictDslBP9i1fhkVm6ZDmZEoNP316zE= diff --git a/x/mint/go.mod b/x/mint/go.mod index b881ce826f23..6305bbf9f42c 100644 --- a/x/mint/go.mod +++ b/x/mint/go.mod @@ -6,7 +6,7 @@ require ( cosmossdk.io/api v0.7.5 cosmossdk.io/collections v0.4.0 cosmossdk.io/core v0.12.1-0.20231114100755-569e3ff6a0d7 - cosmossdk.io/depinject v1.0.0-alpha.4 + cosmossdk.io/depinject v1.0.0 cosmossdk.io/errors v1.0.1 cosmossdk.io/log v1.3.1 cosmossdk.io/math v1.3.0 @@ -181,7 +181,6 @@ replace ( cosmossdk.io/api => ../../api cosmossdk.io/core => ../../core cosmossdk.io/core/testing => ../../core/testing - cosmossdk.io/depinject => ../../depinject cosmossdk.io/log => ../../log cosmossdk.io/x/accounts => ../accounts cosmossdk.io/x/auth => ../auth diff --git a/x/mint/go.sum b/x/mint/go.sum index e79db92d532d..edcd1d37e230 100644 --- a/x/mint/go.sum +++ b/x/mint/go.sum @@ -6,6 +6,8 @@ cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMT cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= cosmossdk.io/collections v0.4.0 h1:PFmwj2W8szgpD5nOd8GWH6AbYNi1f2J6akWXJ7P5t9s= cosmossdk.io/collections v0.4.0/go.mod h1:oa5lUING2dP+gdDquow+QjlF45eL1t4TJDypgGd+tv0= +cosmossdk.io/depinject v1.0.0 h1:dQaTu6+O6askNXO06+jyeUAnF2/ssKwrrszP9t5q050= +cosmossdk.io/depinject v1.0.0/go.mod h1:zxK/h3HgHoA/eJVtiSsoaRaRA2D5U4cJ5thIG4ssbB8= cosmossdk.io/errors v1.0.1 h1:bzu+Kcr0kS/1DuPBtUFdWjzLqyUuCiyHjyJB6srBV/0= cosmossdk.io/errors v1.0.1/go.mod h1:MeelVSZThMi4bEakzhhhE/CKqVv3nOJDA25bIqRDu/U= cosmossdk.io/math v1.3.0 h1:RC+jryuKeytIiictDslBP9i1fhkVm6ZDmZEoNP316zE= diff --git a/x/nft/go.mod b/x/nft/go.mod index 7d7d4bde2bad..28d524d6d9f5 100644 --- a/x/nft/go.mod +++ b/x/nft/go.mod @@ -5,7 +5,7 @@ go 1.22.2 require ( cosmossdk.io/api v0.7.5 cosmossdk.io/core v0.12.1-0.20231114100755-569e3ff6a0d7 - cosmossdk.io/depinject v1.0.0-alpha.4 + cosmossdk.io/depinject v1.0.0 cosmossdk.io/errors v1.0.1 cosmossdk.io/log v1.3.1 cosmossdk.io/math v1.3.0 @@ -177,7 +177,6 @@ replace ( cosmossdk.io/api => ../../api cosmossdk.io/core => ../../core cosmossdk.io/core/testing => ../../core/testing - cosmossdk.io/depinject => ../../depinject cosmossdk.io/log => ../../log cosmossdk.io/x/accounts => ../accounts cosmossdk.io/x/auth => ../auth diff --git a/x/nft/go.sum b/x/nft/go.sum index c2479081cac7..08da56c9d15e 100644 --- a/x/nft/go.sum +++ b/x/nft/go.sum @@ -6,6 +6,8 @@ cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMT cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= cosmossdk.io/collections v0.4.0 h1:PFmwj2W8szgpD5nOd8GWH6AbYNi1f2J6akWXJ7P5t9s= cosmossdk.io/collections v0.4.0/go.mod h1:oa5lUING2dP+gdDquow+QjlF45eL1t4TJDypgGd+tv0= +cosmossdk.io/depinject v1.0.0 h1:dQaTu6+O6askNXO06+jyeUAnF2/ssKwrrszP9t5q050= +cosmossdk.io/depinject v1.0.0/go.mod h1:zxK/h3HgHoA/eJVtiSsoaRaRA2D5U4cJ5thIG4ssbB8= cosmossdk.io/errors v1.0.1 h1:bzu+Kcr0kS/1DuPBtUFdWjzLqyUuCiyHjyJB6srBV/0= cosmossdk.io/errors v1.0.1/go.mod h1:MeelVSZThMi4bEakzhhhE/CKqVv3nOJDA25bIqRDu/U= cosmossdk.io/math v1.3.0 h1:RC+jryuKeytIiictDslBP9i1fhkVm6ZDmZEoNP316zE= diff --git a/x/params/go.mod b/x/params/go.mod index 489b27d3870f..ca7924a8fe9f 100644 --- a/x/params/go.mod +++ b/x/params/go.mod @@ -5,7 +5,7 @@ go 1.22.2 require ( cosmossdk.io/api v0.7.5 cosmossdk.io/core v0.12.1-0.20231114100755-569e3ff6a0d7 - cosmossdk.io/depinject v1.0.0-alpha.4 + cosmossdk.io/depinject v1.0.0 cosmossdk.io/errors v1.0.1 cosmossdk.io/log v1.3.1 cosmossdk.io/math v1.3.0 @@ -178,7 +178,6 @@ replace ( cosmossdk.io/api => ../../api cosmossdk.io/core => ../../core cosmossdk.io/core/testing => ../../core/testing - cosmossdk.io/depinject => ../../depinject cosmossdk.io/log => ../../log cosmossdk.io/x/accounts => ../accounts cosmossdk.io/x/auth => ../auth diff --git a/x/params/go.sum b/x/params/go.sum index c2479081cac7..08da56c9d15e 100644 --- a/x/params/go.sum +++ b/x/params/go.sum @@ -6,6 +6,8 @@ cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMT cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= cosmossdk.io/collections v0.4.0 h1:PFmwj2W8szgpD5nOd8GWH6AbYNi1f2J6akWXJ7P5t9s= cosmossdk.io/collections v0.4.0/go.mod h1:oa5lUING2dP+gdDquow+QjlF45eL1t4TJDypgGd+tv0= +cosmossdk.io/depinject v1.0.0 h1:dQaTu6+O6askNXO06+jyeUAnF2/ssKwrrszP9t5q050= +cosmossdk.io/depinject v1.0.0/go.mod h1:zxK/h3HgHoA/eJVtiSsoaRaRA2D5U4cJ5thIG4ssbB8= cosmossdk.io/errors v1.0.1 h1:bzu+Kcr0kS/1DuPBtUFdWjzLqyUuCiyHjyJB6srBV/0= cosmossdk.io/errors v1.0.1/go.mod h1:MeelVSZThMi4bEakzhhhE/CKqVv3nOJDA25bIqRDu/U= cosmossdk.io/math v1.3.0 h1:RC+jryuKeytIiictDslBP9i1fhkVm6ZDmZEoNP316zE= diff --git a/x/protocolpool/go.mod b/x/protocolpool/go.mod index a0cc4853d437..c0959364d6ad 100644 --- a/x/protocolpool/go.mod +++ b/x/protocolpool/go.mod @@ -6,7 +6,7 @@ require ( cosmossdk.io/api v0.7.5 cosmossdk.io/collections v0.4.0 cosmossdk.io/core v0.12.1-0.20231114100755-569e3ff6a0d7 - cosmossdk.io/depinject v1.0.0-alpha.4 + cosmossdk.io/depinject v1.0.0 cosmossdk.io/errors v1.0.1 cosmossdk.io/log v1.3.1 cosmossdk.io/math v1.3.0 @@ -177,7 +177,6 @@ replace ( cosmossdk.io/api => ../../api cosmossdk.io/core => ../../core cosmossdk.io/core/testing => ../../core/testing - cosmossdk.io/depinject => ../../depinject cosmossdk.io/log => ../../log cosmossdk.io/x/accounts => ../accounts cosmossdk.io/x/auth => ../auth diff --git a/x/protocolpool/go.sum b/x/protocolpool/go.sum index c2479081cac7..08da56c9d15e 100644 --- a/x/protocolpool/go.sum +++ b/x/protocolpool/go.sum @@ -6,6 +6,8 @@ cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMT cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= cosmossdk.io/collections v0.4.0 h1:PFmwj2W8szgpD5nOd8GWH6AbYNi1f2J6akWXJ7P5t9s= cosmossdk.io/collections v0.4.0/go.mod h1:oa5lUING2dP+gdDquow+QjlF45eL1t4TJDypgGd+tv0= +cosmossdk.io/depinject v1.0.0 h1:dQaTu6+O6askNXO06+jyeUAnF2/ssKwrrszP9t5q050= +cosmossdk.io/depinject v1.0.0/go.mod h1:zxK/h3HgHoA/eJVtiSsoaRaRA2D5U4cJ5thIG4ssbB8= cosmossdk.io/errors v1.0.1 h1:bzu+Kcr0kS/1DuPBtUFdWjzLqyUuCiyHjyJB6srBV/0= cosmossdk.io/errors v1.0.1/go.mod h1:MeelVSZThMi4bEakzhhhE/CKqVv3nOJDA25bIqRDu/U= cosmossdk.io/math v1.3.0 h1:RC+jryuKeytIiictDslBP9i1fhkVm6ZDmZEoNP316zE= diff --git a/x/slashing/go.mod b/x/slashing/go.mod index 0c254b35add6..b60bdb431e11 100644 --- a/x/slashing/go.mod +++ b/x/slashing/go.mod @@ -7,7 +7,7 @@ require ( cosmossdk.io/collections v0.4.0 cosmossdk.io/core v0.12.1-0.20231114100755-569e3ff6a0d7 cosmossdk.io/core/testing v0.0.0-00010101000000-000000000000 - cosmossdk.io/depinject v1.0.0-alpha.4 + cosmossdk.io/depinject v1.0.0 cosmossdk.io/errors v1.0.1 cosmossdk.io/math v1.3.0 cosmossdk.io/store v1.1.1-0.20240418092142-896cdf1971bc @@ -178,7 +178,6 @@ replace ( cosmossdk.io/api => ../../api cosmossdk.io/core => ../../core cosmossdk.io/core/testing => ../../core/testing - cosmossdk.io/depinject => ../../depinject cosmossdk.io/log => ../../log cosmossdk.io/x/accounts => ../accounts cosmossdk.io/x/auth => ../auth diff --git a/x/slashing/go.sum b/x/slashing/go.sum index 7bcffe139a9a..283361751656 100644 --- a/x/slashing/go.sum +++ b/x/slashing/go.sum @@ -6,6 +6,8 @@ cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMT cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= cosmossdk.io/collections v0.4.0 h1:PFmwj2W8szgpD5nOd8GWH6AbYNi1f2J6akWXJ7P5t9s= cosmossdk.io/collections v0.4.0/go.mod h1:oa5lUING2dP+gdDquow+QjlF45eL1t4TJDypgGd+tv0= +cosmossdk.io/depinject v1.0.0 h1:dQaTu6+O6askNXO06+jyeUAnF2/ssKwrrszP9t5q050= +cosmossdk.io/depinject v1.0.0/go.mod h1:zxK/h3HgHoA/eJVtiSsoaRaRA2D5U4cJ5thIG4ssbB8= cosmossdk.io/errors v1.0.1 h1:bzu+Kcr0kS/1DuPBtUFdWjzLqyUuCiyHjyJB6srBV/0= cosmossdk.io/errors v1.0.1/go.mod h1:MeelVSZThMi4bEakzhhhE/CKqVv3nOJDA25bIqRDu/U= cosmossdk.io/math v1.3.0 h1:RC+jryuKeytIiictDslBP9i1fhkVm6ZDmZEoNP316zE= diff --git a/x/staking/go.mod b/x/staking/go.mod index 9c3d495a8859..5ad5d4f275cf 100644 --- a/x/staking/go.mod +++ b/x/staking/go.mod @@ -7,7 +7,7 @@ require ( cosmossdk.io/collections v0.4.0 cosmossdk.io/core v0.12.1-0.20231114100755-569e3ff6a0d7 cosmossdk.io/core/testing v0.0.0-00010101000000-000000000000 - cosmossdk.io/depinject v1.0.0-alpha.4 + cosmossdk.io/depinject v1.0.0 cosmossdk.io/errors v1.0.1 cosmossdk.io/math v1.3.0 cosmossdk.io/store v1.1.1-0.20240418092142-896cdf1971bc @@ -183,7 +183,6 @@ replace ( cosmossdk.io/collections => ../../collections cosmossdk.io/core => ../../core cosmossdk.io/core/testing => ../../core/testing - cosmossdk.io/depinject => ../../depinject cosmossdk.io/log => ../../log cosmossdk.io/x/accounts => ../accounts cosmossdk.io/x/auth => ../auth diff --git a/x/staking/go.sum b/x/staking/go.sum index 7c6b086874ef..4879cfa34550 100644 --- a/x/staking/go.sum +++ b/x/staking/go.sum @@ -4,6 +4,8 @@ buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.34.2-20240130113600-88e buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.34.2-20240130113600-88ef6483f90f.2/go.mod h1:HqcXMSa5qnNuakaMUo+hWhF51mKbcrZxGl9Vp5EeJXc= cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= +cosmossdk.io/depinject v1.0.0 h1:dQaTu6+O6askNXO06+jyeUAnF2/ssKwrrszP9t5q050= +cosmossdk.io/depinject v1.0.0/go.mod h1:zxK/h3HgHoA/eJVtiSsoaRaRA2D5U4cJ5thIG4ssbB8= cosmossdk.io/errors v1.0.1 h1:bzu+Kcr0kS/1DuPBtUFdWjzLqyUuCiyHjyJB6srBV/0= cosmossdk.io/errors v1.0.1/go.mod h1:MeelVSZThMi4bEakzhhhE/CKqVv3nOJDA25bIqRDu/U= cosmossdk.io/math v1.3.0 h1:RC+jryuKeytIiictDslBP9i1fhkVm6ZDmZEoNP316zE= diff --git a/x/upgrade/go.mod b/x/upgrade/go.mod index d530f48a27b0..e646726b215b 100644 --- a/x/upgrade/go.mod +++ b/x/upgrade/go.mod @@ -6,7 +6,7 @@ require ( cosmossdk.io/api v0.7.5 cosmossdk.io/core v0.12.1-0.20231114100755-569e3ff6a0d7 cosmossdk.io/core/testing v0.0.0-00010101000000-000000000000 - cosmossdk.io/depinject v1.0.0-alpha.4 + cosmossdk.io/depinject v1.0.0 cosmossdk.io/errors v1.0.1 cosmossdk.io/log v1.3.1 cosmossdk.io/store v1.1.1-0.20240418092142-896cdf1971bc @@ -208,7 +208,6 @@ replace ( cosmossdk.io/api => ../../api cosmossdk.io/core => ../../core cosmossdk.io/core/testing => ../../core/testing - cosmossdk.io/depinject => ../../depinject cosmossdk.io/log => ../../log cosmossdk.io/x/accounts => ../accounts cosmossdk.io/x/auth => ../auth diff --git a/x/upgrade/go.sum b/x/upgrade/go.sum index 5987b2057dcd..7d486fa36fef 100644 --- a/x/upgrade/go.sum +++ b/x/upgrade/go.sum @@ -194,6 +194,8 @@ cloud.google.com/go/workflows v1.6.0/go.mod h1:6t9F5h/unJz41YqfBmqSASJSXccBLtD1V cloud.google.com/go/workflows v1.7.0/go.mod h1:JhSrZuVZWuiDfKEFxU0/F1PQjmpnpcoISEXH2bcHC3M= cosmossdk.io/collections v0.4.0 h1:PFmwj2W8szgpD5nOd8GWH6AbYNi1f2J6akWXJ7P5t9s= cosmossdk.io/collections v0.4.0/go.mod h1:oa5lUING2dP+gdDquow+QjlF45eL1t4TJDypgGd+tv0= +cosmossdk.io/depinject v1.0.0 h1:dQaTu6+O6askNXO06+jyeUAnF2/ssKwrrszP9t5q050= +cosmossdk.io/depinject v1.0.0/go.mod h1:zxK/h3HgHoA/eJVtiSsoaRaRA2D5U4cJ5thIG4ssbB8= cosmossdk.io/errors v1.0.1 h1:bzu+Kcr0kS/1DuPBtUFdWjzLqyUuCiyHjyJB6srBV/0= cosmossdk.io/errors v1.0.1/go.mod h1:MeelVSZThMi4bEakzhhhE/CKqVv3nOJDA25bIqRDu/U= cosmossdk.io/math v1.3.0 h1:RC+jryuKeytIiictDslBP9i1fhkVm6ZDmZEoNP316zE= From d80eba9bf9a7601a99f9cfb842c9d1e7a46670cf Mon Sep 17 00:00:00 2001 From: Julien Robert Date: Tue, 23 Jul 2024 16:00:33 +0200 Subject: [PATCH 30/50] chore(core): sync changelog (#21025) --- core/CHANGELOG.md | 12 ++++-------- core/go.mod | 3 +++ 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/core/CHANGELOG.md b/core/CHANGELOG.md index 7be6d889bf8a..bd95f6aabc02 100644 --- a/core/CHANGELOG.md +++ b/core/CHANGELOG.md @@ -62,19 +62,15 @@ Ref: https://keepachangelog.com/en/1.0.0/ * [#18861](https://github.com/cosmos/cosmos-sdk/pull/18861) Moved `coin.ParseCoin` to `client/v2/internal`. * [#18866](https://github.com/cosmos/cosmos-sdk/pull/18866) All items related to depinject have been moved to `cosmossdk.io/depinject` (`Provide`, `Invoke`, `Register`) * [#19041](https://github.com/cosmos/cosmos-sdk/pull/19041) `HasEventListeners` was removed from appmodule due to the fact that it was not used anywhere in the SDK nor implemented - -## [v0.12.0](https://github.com/cosmos/cosmos-sdk/releases/tag/core%2Fv0.12.0) - -:::note -This release contains breaking changes and should not be used with 0.50.x or earlier versions of the Cosmos SDK. -::: - * [#17689](https://github.com/cosmos/cosmos-sdk/pull/17689) Move Comet service to return structs instead of interfaces. * `BlockInfo` was renamed to `Info` and `BlockInfoService` was renamed to `CometInfoService` * [#17693](https://github.com/cosmos/cosmos-sdk/pull/17693) Remove `appmodule.UpgradeModule` interface in favor of preblock -## [v0.11.0](https://github.com/cosmos/cosmos-sdk/releases/tag/core%2Fv0.11.0) +## [v0.11.1](https://github.com/cosmos/cosmos-sdk/releases/tag/core%2Fv0.11.1) + +* [#21022](https://github.com/cosmos/cosmos-sdk/pull/21022) Upgrade depinject to v1.0.0. +## [v0.11.0](https://github.com/cosmos/cosmos-sdk/releases/tag/core%2Fv0.11.0) * [#17468](https://github.com/cosmos/cosmos-sdk/pull/17468) Add `appmodule.HasPreBlocker` interface. diff --git a/core/go.mod b/core/go.mod index 640023bbfb5d..d6dc5f94cd27 100644 --- a/core/go.mod +++ b/core/go.mod @@ -16,3 +16,6 @@ require ( google.golang.org/genproto/googleapis/rpc v0.0.0-20240709173604-40e1e62336c5 // indirect google.golang.org/protobuf v1.34.2 // indirect ) + +// Version tagged too early and incompatible with v0.50 (latest at the time of tagging) +retract v0.12.0 From 2c236af94d679569286cc26d8cb90799f4a57f53 Mon Sep 17 00:00:00 2001 From: Aaron Craelius Date: Tue, 23 Jul 2024 16:35:20 +0200 Subject: [PATCH 31/50] refactor(schema)!: move bech32 address prefixes to a higher level (#21026) --- schema/field.go | 11 ----------- schema/field_test.go | 17 ----------------- schema/kind.go | 14 +++++++------- schema/kind_test.go | 6 +++--- 4 files changed, 10 insertions(+), 38 deletions(-) diff --git a/schema/field.go b/schema/field.go index 19a1b4085dd6..a11cc756683f 100644 --- a/schema/field.go +++ b/schema/field.go @@ -13,10 +13,6 @@ type Field struct { // Nullable indicates whether null values are accepted for the field. Key fields CANNOT be nullable. Nullable bool - // AddressPrefix is the address prefix of the field's kind, currently only used for Bech32AddressKind. - // TODO: in a future update, stricter criteria and validation for address prefixes should be added. - AddressPrefix string - // EnumDefinition is the definition of the enum type and is only valid when Kind is EnumKind. // The same enum types can be reused in the same module schema, but they always must contain // the same values for the same enum name. This possibly introduces some duplication of @@ -36,13 +32,6 @@ func (c Field) Validate() error { return fmt.Errorf("invalid field kind for %q: %v", c.Name, err) //nolint:errorlint // false positive due to using go1.12 } - // address prefix only valid with Bech32AddressKind - if c.Kind == Bech32AddressKind && c.AddressPrefix == "" { - return fmt.Errorf("missing address prefix for field %q", c.Name) - } else if c.Kind != Bech32AddressKind && c.AddressPrefix != "" { - return fmt.Errorf("address prefix is only valid for field %q with type Bech32AddressKind", c.Name) - } - // enum definition only valid with EnumKind if c.Kind == EnumKind { if err := c.EnumDefinition.Validate(); err != nil { diff --git a/schema/field_test.go b/schema/field_test.go index a1f8087fff6a..ea839ece08cb 100644 --- a/schema/field_test.go +++ b/schema/field_test.go @@ -35,23 +35,6 @@ func TestField_Validate(t *testing.T) { }, errContains: "invalid field kind", }, - { - name: "missing address prefix", - field: Field{ - Name: "field1", - Kind: Bech32AddressKind, - }, - errContains: "missing address prefix", - }, - { - name: "address prefix with non-Bech32AddressKind", - field: Field{ - Name: "field1", - Kind: StringKind, - AddressPrefix: "prefix", - }, - errContains: "address prefix is only valid for field \"field1\" with type Bech32AddressKind", - }, { name: "invalid enum definition", field: Field{ diff --git a/schema/kind.go b/schema/kind.go index c3fefad52c8a..c28ce34af046 100644 --- a/schema/kind.go +++ b/schema/kind.go @@ -72,10 +72,10 @@ const ( // Float64Kind is a float64 type and values of this type must be of the go type float64. Float64Kind - // Bech32AddressKind is a bech32 address type and values of this type must be of the go type []byte. - // Fields of this type are expected to set the AddressPrefix field in the field definition to the - // bech32 address prefix so that indexers can properly convert them to strings. - Bech32AddressKind + // AddressKind represents an account address and must be of type []byte. Addresses usually have a + // human-readable rendering, such as bech32, and tooling should provide a way for apps to define a + // string encoder for friendly user-facing display. + AddressKind // EnumKind is an enum type and values of this type must be of the go type string. // Fields of this type are expected to set the EnumDefinition field in the field definition to the enum @@ -150,7 +150,7 @@ func (t Kind) String() string { return "float32" case Float64Kind: return "float64" - case Bech32AddressKind: + case AddressKind: return "bech32address" case EnumKind: return "enum" @@ -254,7 +254,7 @@ func (t Kind) ValidateValueType(value interface{}) error { if !ok { return fmt.Errorf("expected float64, got %T", value) } - case Bech32AddressKind: + case AddressKind: _, ok := value.([]byte) if !ok { return fmt.Errorf("expected []byte, got %T", value) @@ -321,7 +321,7 @@ var ( ) // KindForGoValue finds the simplest kind that can represent the given go value. It will not, however, -// return kinds such as IntegerStringKind, DecimalStringKind, Bech32AddressKind, or EnumKind which all can be +// return kinds such as IntegerStringKind, DecimalStringKind, AddressKind, or EnumKind which all can be // represented as strings. func KindForGoValue(value interface{}) Kind { switch value.(type) { diff --git a/schema/kind_test.go b/schema/kind_test.go index 49799fe4956c..113762ec2e59 100644 --- a/schema/kind_test.go +++ b/schema/kind_test.go @@ -59,8 +59,8 @@ func TestKind_ValidateValueType(t *testing.T) { {kind: DecimalStringKind, value: "1", valid: true}, {kind: DecimalStringKind, value: "1.1e4", valid: true}, {kind: DecimalStringKind, value: int32(1), valid: false}, - {kind: Bech32AddressKind, value: []byte("hello"), valid: true}, - {kind: Bech32AddressKind, value: 1, valid: false}, + {kind: AddressKind, value: []byte("hello"), valid: true}, + {kind: AddressKind, value: 1, valid: false}, {kind: BoolKind, value: true, valid: true}, {kind: BoolKind, value: false, valid: true}, {kind: BoolKind, value: 1, valid: false}, @@ -213,7 +213,7 @@ func TestKind_String(t *testing.T) { {Float64Kind, "float64"}, {JSONKind, "json"}, {EnumKind, "enum"}, - {Bech32AddressKind, "bech32address"}, + {AddressKind, "bech32address"}, {InvalidKind, "invalid(0)"}, } for i, tt := range tests { From 0ca95ee5eb796d0811b6b911aa851812f7c1ed1a Mon Sep 17 00:00:00 2001 From: Hieu Vu <72878483+hieuvubk@users.noreply.github.com> Date: Tue, 23 Jul 2024 23:48:54 +0700 Subject: [PATCH 32/50] feat(server/v2) Add prune cmd to serverv2 (#20736) --- runtime/v2/builder.go | 27 +++++ runtime/v2/go.mod | 17 ++- runtime/v2/go.sum | 37 ++++++- runtime/v2/module.go | 10 +- runtime/v2/types.go | 5 +- server/v2/go.mod | 25 ++++- server/v2/go.sum | 95 +++++++++++++++++ server/v2/store/commands.go | 163 +++++++++++++++++++++++++++++ server/v2/store/config.go | 17 +++ server/v2/store/flags.go | 6 ++ server/v2/store/server.go | 76 ++++++++++++++ simapp/v2/app_di.go | 25 +---- simapp/v2/go.mod | 4 +- simapp/v2/simdv2/cmd/commands.go | 2 + store/v2/commitment/iavl/config.go | 4 +- store/v2/go.mod | 4 +- store/v2/go.sum | 7 +- store/v2/options.go | 5 +- store/v2/root/factory.go | 51 ++++++--- store/v2/root/store.go | 4 + store/v2/store.go | 2 + 21 files changed, 527 insertions(+), 59 deletions(-) create mode 100644 server/v2/store/commands.go create mode 100644 server/v2/store/config.go create mode 100644 server/v2/store/flags.go create mode 100644 server/v2/store/server.go diff --git a/runtime/v2/builder.go b/runtime/v2/builder.go index 82e418349d56..a073761cbcf1 100644 --- a/runtime/v2/builder.go +++ b/runtime/v2/builder.go @@ -5,6 +5,9 @@ import ( "encoding/json" "fmt" "io" + "path/filepath" + + "github.com/spf13/viper" "cosmossdk.io/core/appmodule" appmodulev2 "cosmossdk.io/core/appmodule/v2" @@ -13,6 +16,7 @@ import ( "cosmossdk.io/server/v2/appmanager" "cosmossdk.io/server/v2/stf" "cosmossdk.io/server/v2/stf/branch" + "cosmossdk.io/store/v2/db" rootstore "cosmossdk.io/store/v2/root" ) @@ -22,6 +26,7 @@ import ( type AppBuilder[T transaction.Tx] struct { app *App[T] storeOptions *rootstore.FactoryOptions + viper *viper.Viper // the following fields are used to overwrite the default branch func(state store.ReaderMap) store.WriterMap @@ -119,6 +124,28 @@ func (a *AppBuilder[T]) Build(opts ...AppBuilderOption[T]) (*App[T], error) { } a.app.stf = stf + v := a.viper + home := v.GetString(FlagHome) + + storeOpts := rootstore.DefaultStoreOptions() + if err := v.Sub("store.options").Unmarshal(&storeOpts); err != nil { + return nil, fmt.Errorf("failed to store options: %w", err) + } + + scRawDb, err := db.NewDB(db.DBType(v.GetString("store.app-db-backend")), "application", filepath.Join(home, "data"), nil) + if err != nil { + panic(err) + } + + storeOptions := &rootstore.FactoryOptions{ + Logger: a.app.logger, + RootDir: home, + Options: storeOpts, + StoreKeys: append(a.app.storeKeys, "stf"), + SCRawDB: scRawDb, + } + a.storeOptions = storeOptions + rs, err := rootstore.CreateRootStore(a.storeOptions) if err != nil { return nil, fmt.Errorf("failed to create root store: %w", err) diff --git a/runtime/v2/go.mod b/runtime/v2/go.mod index 50c759c959b6..deca135c16fe 100644 --- a/runtime/v2/go.mod +++ b/runtime/v2/go.mod @@ -8,6 +8,7 @@ replace ( cosmossdk.io/core => ../../core cosmossdk.io/core/testing => ../../core/testing cosmossdk.io/log => ../../log + cosmossdk.io/server/v2 => ../../server/v2 cosmossdk.io/server/v2/appmanager => ../../server/v2/appmanager cosmossdk.io/server/v2/stf => ../../server/v2/stf cosmossdk.io/store/v2 => ../../store/v2 @@ -30,7 +31,8 @@ require ( cosmossdk.io/store/v2 v2.0.0-00010101000000-000000000000 cosmossdk.io/x/tx v0.13.3 github.com/cosmos/gogoproto v1.5.0 - golang.org/x/exp v0.0.0-20240506185415-9bf2ced13842 + github.com/spf13/viper v1.19.0 + golang.org/x/exp v0.0.0-20240531132922-fd00a4e0eefc google.golang.org/grpc v1.64.1 google.golang.org/protobuf v1.34.2 ) @@ -55,6 +57,7 @@ require ( github.com/cosmos/ics23/go v0.10.0 // indirect github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect github.com/emicklei/dot v1.6.2 // indirect + github.com/fsnotify/fsnotify v1.7.0 // indirect github.com/getsentry/sentry-go v0.27.0 // indirect github.com/gogo/protobuf v1.3.2 // indirect github.com/golang/snappy v0.0.4 // indirect @@ -63,15 +66,19 @@ require ( github.com/hashicorp/go-immutable-radix v1.3.1 // indirect github.com/hashicorp/go-metrics v0.5.3 // indirect github.com/hashicorp/golang-lru v1.0.2 // indirect + github.com/hashicorp/hcl v1.0.0 // indirect github.com/klauspost/compress v1.17.8 // indirect github.com/kr/pretty v0.3.1 // indirect github.com/kr/text v0.2.0 // indirect github.com/linxGnu/grocksdb v1.8.14 // indirect + github.com/magiconair/properties v1.8.7 // indirect github.com/mattn/go-colorable v0.1.13 // indirect github.com/mattn/go-isatty v0.0.20 // indirect github.com/mattn/go-sqlite3 v1.14.22 // indirect + github.com/mitchellh/mapstructure v1.5.0 // indirect github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect github.com/onsi/gomega v1.28.1 // indirect + github.com/pelletier/go-toml/v2 v2.2.2 // indirect github.com/pkg/errors v0.9.1 // indirect github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect github.com/prometheus/client_golang v1.19.1 // indirect @@ -80,11 +87,18 @@ require ( github.com/prometheus/procfs v0.15.1 // indirect github.com/rogpeppe/go-internal v1.12.0 // indirect github.com/rs/zerolog v1.33.0 // indirect + github.com/sagikazarmark/locafero v0.4.0 // indirect + github.com/sagikazarmark/slog-shim v0.1.0 // indirect + github.com/sourcegraph/conc v0.3.0 // indirect + github.com/spf13/afero v1.11.0 // indirect github.com/spf13/cast v1.6.0 // indirect + github.com/spf13/pflag v1.0.5 // indirect github.com/stretchr/testify v1.9.0 // indirect + github.com/subosito/gotenv v1.6.0 // indirect github.com/syndtr/goleveldb v1.0.1-0.20220721030215-126854af5e6d // indirect github.com/tendermint/go-amino v0.16.0 // indirect github.com/tidwall/btree v1.7.0 // indirect + go.uber.org/multierr v1.11.0 // indirect golang.org/x/crypto v0.25.0 // indirect golang.org/x/net v0.27.0 // indirect golang.org/x/sync v0.7.0 // indirect @@ -92,6 +106,7 @@ require ( golang.org/x/text v0.16.0 // indirect google.golang.org/genproto/googleapis/api v0.0.0-20240318140521-94a12d6c2237 // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20240709173604-40e1e62336c5 // indirect + gopkg.in/ini.v1 v1.67.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect sigs.k8s.io/yaml v1.4.0 // indirect ) diff --git a/runtime/v2/go.sum b/runtime/v2/go.sum index 3f00d777d26a..a37bf08a3944 100644 --- a/runtime/v2/go.sum +++ b/runtime/v2/go.sum @@ -121,6 +121,8 @@ github.com/hashicorp/go-uuid v1.0.1/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/b github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/hashicorp/golang-lru v1.0.2 h1:dV3g9Z/unq5DpblPpw+Oqcv4dU/1omnb4Ok8iPY6p1c= github.com/hashicorp/golang-lru v1.0.2/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4= +github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4= +github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= @@ -141,6 +143,8 @@ github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/linxGnu/grocksdb v1.8.14 h1:HTgyYalNwBSG/1qCQUIott44wU5b2Y9Kr3z7SK5OfGQ= github.com/linxGnu/grocksdb v1.8.14/go.mod h1:QYiYypR2d4v63Wj1adOOfzglnoII0gLj3PNh4fZkcFA= +github.com/magiconair/properties v1.8.7 h1:IeQXZAiQcpL9mgcAe1Nu6cX9LLw6ExEHKjN0VQdvPDY= +github.com/magiconair/properties v1.8.7/go.mod h1:Dhd985XPs7jluiymwWYZ0G4Z61jb3vdS329zhj2hYo0= github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= @@ -150,6 +154,8 @@ github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D github.com/mattn/go-sqlite3 v1.14.22 h1:2gZY6PC6kBnID23Tichd1K+Z0oS6nE/XwU+Vz/5o4kU= github.com/mattn/go-sqlite3 v1.14.22/go.mod h1:Uh1q+B4BYcTPb+yiD3kU8Ct7aC0hY9fxUwlHK0RXw+Y= github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= +github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY= +github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= @@ -174,6 +180,8 @@ github.com/onsi/gomega v1.28.1 h1:MijcGUbfYuznzK/5R4CPNoUP/9Xvuo20sXfEm6XxoTA= github.com/onsi/gomega v1.28.1/go.mod h1:9sxs+SwGrKI0+PWe4Fxa9tFQQBG5xSsSbMXOI8PPpoQ= github.com/pascaldekloe/goe v0.1.0 h1:cBOtyMzM9HTpWjXfbbunk26uA6nG3a8n06Wieeh0MwY= github.com/pascaldekloe/goe v0.1.0/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= +github.com/pelletier/go-toml/v2 v2.2.2 h1:aYUidT7k73Pcl9nb2gScu7NSrKCSHIDE89b3+6Wq+LM= +github.com/pelletier/go-toml/v2 v2.2.2/go.mod h1:1t835xjRzz80PqgE6HHgN2JOsmgYu/h4qDAS4n929Rs= github.com/pingcap/errors v0.11.4 h1:lFuQV/oaUMGcD2tqt+01ROSmJs75VG1ToEOkZIZ4nE4= github.com/pingcap/errors v0.11.4/go.mod h1:Oi8TUi2kEtXXLMJk9l1cGmz20kV3TaQ0usTwv5KuLY8= github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA= @@ -209,19 +217,39 @@ github.com/rogpeppe/go-internal v1.12.0/go.mod h1:E+RYuTGaKKdloAfM02xzb0FW3Paa99 github.com/rs/xid v1.5.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg= github.com/rs/zerolog v1.33.0 h1:1cU2KZkvPxNyfgEmhHAz/1A9Bz+llsdYzklWFzgp0r8= github.com/rs/zerolog v1.33.0/go.mod h1:/7mN4D5sKwJLZQ2b/znpjC3/GQWY/xaDXUM0kKWRHss= +github.com/sagikazarmark/locafero v0.4.0 h1:HApY1R9zGo4DBgr7dqsTH/JJxLTTsOt7u6keLGt6kNQ= +github.com/sagikazarmark/locafero v0.4.0/go.mod h1:Pe1W6UlPYUk/+wc/6KFhbORCfqzgYEpgQ3O5fPuL3H4= +github.com/sagikazarmark/slog-shim v0.1.0 h1:diDBnUNK9N/354PgrxMywXnAwEr1QZcOr6gto+ugjYE= +github.com/sagikazarmark/slog-shim v0.1.0/go.mod h1:SrcSrq8aKtyuqEI1uvTDTK1arOWRIczQRv+GVI1AkeQ= github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= +github.com/sourcegraph/conc v0.3.0 h1:OQTbbt6P72L20UqAkXXuLOj79LfEanQ+YQFNpLA9ySo= +github.com/sourcegraph/conc v0.3.0/go.mod h1:Sdozi7LEKbFPqYX2/J+iBAM6HpqSLTASQIKqDmF7Mt0= +github.com/spf13/afero v1.11.0 h1:WJQKhtpdm3v2IzqG8VMqrr6Rf3UYpEF239Jy9wNepM8= +github.com/spf13/afero v1.11.0/go.mod h1:GH9Y3pIexgf1MTIWtNGyogA5MwRIDXGUr+hbWNoBjkY= github.com/spf13/cast v1.6.0 h1:GEiTHELF+vaR5dhz3VqZfFSzZjYbgeKDpBxQVS4GYJ0= github.com/spf13/cast v1.6.0/go.mod h1:ancEpBxwJDODSW/UG4rDrAqiKolqNNh2DX3mk86cAdo= +github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= +github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= +github.com/spf13/viper v1.19.0 h1:RWq5SEjt8o25SROyN3z2OrDB9l7RPd3lwTWU8EcEdcI= +github.com/spf13/viper v1.19.0/go.mod h1:GQUN9bilAbhU/jgc1bKs99f/suXKeUMct8Adx5+Ntkg= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= +github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= +github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= +github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.2/go.mod h1:R6va5+xMeoiuVRoj+gSkQ7d3FALtqAAGI1FQKckRals= +github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= +github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= +github.com/subosito/gotenv v1.6.0 h1:9NlTDc1FTs4qu0DDq7AEtTPNw6SVm7uBMsUCUjABIf8= +github.com/subosito/gotenv v1.6.0/go.mod h1:Dk4QP5c2W3ibzajGcXpNraDfq2IrhjMIvMSWPKKo0FU= github.com/syndtr/goleveldb v1.0.1-0.20220721030215-126854af5e6d h1:vfofYNRScrDdvS342BElfbETmL1Aiz3i2t0zfRj16Hs= github.com/syndtr/goleveldb v1.0.1-0.20220721030215-126854af5e6d/go.mod h1:RRCYJbIwD5jmqPI9XoAFR0OcDxqUctll6zUj/+B4S48= github.com/tendermint/go-amino v0.16.0 h1:GyhmgQKvqF82e2oZeuMSp9JTN0N09emoSZlb2lyGa2E= @@ -231,14 +259,16 @@ github.com/tidwall/btree v1.7.0/go.mod h1:twD9XRA5jj9VUQGELzDO4HPQTNJsoWWfYEL+EU github.com/tv42/httpunix v0.0.0-20150427012821-b75d8614f926/go.mod h1:9ESjWnEqriFuLhtthL60Sar/7RFoluCcXsuvEwTV5KM= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0= +go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.25.0 h1:ypSNr+bnYL2YhwoMt2zPxHFmbAN1KZs/njMG3hxUp30= golang.org/x/crypto v0.25.0/go.mod h1:T+wALwcMOSE0kXgUAnPAHqTLW+XHgcELELW8VaDgm/M= -golang.org/x/exp v0.0.0-20240506185415-9bf2ced13842 h1:vr/HnozRka3pE4EsMEg1lgkXJkTFJCVUX+S/ZT6wYzM= -golang.org/x/exp v0.0.0-20240506185415-9bf2ced13842/go.mod h1:XtvwrStGgqGPLc4cjQfWqZHG1YFdYs6swckp8vpsjnc= +golang.org/x/exp v0.0.0-20240531132922-fd00a4e0eefc h1:O9NuF4s+E/PvMIy+9IUZB9znFwUIXEWSstNjek6VpVg= +golang.org/x/exp v0.0.0-20240531132922-fd00a4e0eefc/go.mod h1:XtvwrStGgqGPLc4cjQfWqZHG1YFdYs6swckp8vpsjnc= golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -329,6 +359,8 @@ gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8 gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= +gopkg.in/ini.v1 v1.67.0 h1:Dgnx+6+nfE+IfzjUEISNeydPJh9AXNNsWbGP9KzCsOA= +gopkg.in/ini.v1 v1.67.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= @@ -337,6 +369,7 @@ gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.5/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gotest.tools/v3 v3.5.1 h1:EENdUnS3pdur5nybKYIh2Vfgc8IUNBjxDPSjtiJcOzU= diff --git a/runtime/v2/module.go b/runtime/v2/module.go index ffc5632f9403..cb0ec169d315 100644 --- a/runtime/v2/module.go +++ b/runtime/v2/module.go @@ -6,6 +6,7 @@ import ( "slices" "github.com/cosmos/gogoproto/proto" + "github.com/spf13/viper" "google.golang.org/grpc" "google.golang.org/protobuf/reflect/protodesc" "google.golang.org/protobuf/reflect/protoregistry" @@ -28,7 +29,6 @@ import ( "cosmossdk.io/depinject/appconfig" "cosmossdk.io/runtime/v2/services" "cosmossdk.io/server/v2/stf" - rootstorev2 "cosmossdk.io/store/v2/root" ) var ( @@ -151,7 +151,7 @@ type AppInputs struct { InterfaceRegistrar registry.InterfaceRegistrar LegacyAmino legacy.Amino Logger log.Logger - StoreOptions *rootstorev2.FactoryOptions `optional:"true"` + Viper *viper.Viper `optional:"true"` } func SetupAppBuilder(inputs AppInputs) { @@ -163,10 +163,8 @@ func SetupAppBuilder(inputs AppInputs) { app.moduleManager.RegisterInterfaces(inputs.InterfaceRegistrar) app.moduleManager.RegisterLegacyAminoCodec(inputs.LegacyAmino) - if inputs.StoreOptions != nil { - inputs.AppBuilder.storeOptions = inputs.StoreOptions - inputs.AppBuilder.storeOptions.StoreKeys = inputs.AppBuilder.app.storeKeys - inputs.AppBuilder.storeOptions.StoreKeys = append(inputs.AppBuilder.storeOptions.StoreKeys, "stf") + if inputs.Viper != nil { + inputs.AppBuilder.viper = inputs.Viper } } diff --git a/runtime/v2/types.go b/runtime/v2/types.go index ac606cbd5457..0138dd802c82 100644 --- a/runtime/v2/types.go +++ b/runtime/v2/types.go @@ -12,7 +12,10 @@ import ( "cosmossdk.io/x/tx/signing" ) -const ModuleName = "runtime" +const ( + ModuleName = "runtime" + FlagHome = "home" +) // ValidateProtoAnnotations validates that the proto annotations are correct. // More specifically, it verifies: diff --git a/server/v2/go.mod b/server/v2/go.mod index 31e857839fa9..95e4c2f9d18c 100644 --- a/server/v2/go.mod +++ b/server/v2/go.mod @@ -9,6 +9,8 @@ replace ( cosmossdk.io/log => ../../log cosmossdk.io/server/v2/appmanager => ./appmanager cosmossdk.io/server/v2/stf => ./stf + cosmossdk.io/store/v2 => ../../store/v2 + cosmossdk.io/store/v2/db => ../../store/v2/db cosmossdk.io/x/tx => ../../x/tx ) @@ -18,6 +20,7 @@ require ( cosmossdk.io/core/testing v0.0.0-00010101000000-000000000000 cosmossdk.io/log v1.3.1 cosmossdk.io/server/v2/appmanager v0.0.0-00010101000000-000000000000 + cosmossdk.io/store/v2 v2.0.0-00010101000000-000000000000 github.com/cosmos/cosmos-proto v1.0.0-beta.5 github.com/cosmos/gogogateway v1.2.0 github.com/cosmos/gogoproto v1.5.0 @@ -42,25 +45,43 @@ require ( ) require ( + cosmossdk.io/errors v1.0.1 // indirect github.com/DataDog/datadog-go v3.2.0+incompatible // indirect + github.com/DataDog/zstd v1.5.5 // indirect github.com/beorn7/perks v1.0.1 // indirect github.com/cespare/xxhash/v2 v2.3.0 // indirect + github.com/cockroachdb/errors v1.11.1 // indirect + github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b // indirect + github.com/cockroachdb/pebble v1.1.0 // indirect + github.com/cockroachdb/redact v1.1.5 // indirect + github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06 // indirect + github.com/cosmos/cosmos-db v1.0.2 // indirect + github.com/cosmos/iavl v1.2.0 // indirect + github.com/cosmos/ics23/go v0.10.0 // indirect github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect + github.com/emicklei/dot v1.6.1 // indirect github.com/fatih/color v1.15.0 // indirect github.com/fsnotify/fsnotify v1.7.0 // indirect + github.com/getsentry/sentry-go v0.27.0 // indirect github.com/gogo/googleapis v1.4.1 // indirect github.com/gogo/protobuf v1.3.2 // indirect + github.com/golang/snappy v0.0.4 // indirect + github.com/google/btree v1.1.2 // indirect github.com/google/go-cmp v0.6.0 // indirect github.com/hashicorp/go-immutable-radix v1.3.1 // indirect - github.com/hashicorp/go-uuid v1.0.1 // indirect github.com/hashicorp/golang-lru v1.0.2 // indirect github.com/hashicorp/hcl v1.0.0 // indirect github.com/hashicorp/yamux v0.1.1 // indirect github.com/inconshreveable/mousetrap v1.1.0 // indirect github.com/jhump/protoreflect v1.15.3 // indirect + github.com/klauspost/compress v1.17.7 // indirect + github.com/kr/pretty v0.3.1 // indirect + github.com/kr/text v0.2.0 // indirect + github.com/linxGnu/grocksdb v1.8.14 // indirect github.com/magiconair/properties v1.8.7 // indirect github.com/mattn/go-colorable v0.1.13 // indirect github.com/mattn/go-isatty v0.0.20 // indirect + github.com/mattn/go-sqlite3 v1.14.22 // indirect github.com/mitchellh/go-testing-interface v1.14.1 // indirect github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect github.com/oklog/run v1.1.0 // indirect @@ -75,8 +96,10 @@ require ( github.com/spf13/afero v1.11.0 // indirect github.com/spf13/cast v1.6.0 // indirect github.com/subosito/gotenv v1.6.0 // indirect + github.com/syndtr/goleveldb v1.0.1-0.20220721030215-126854af5e6d // indirect github.com/tidwall/btree v1.7.0 // indirect go.uber.org/multierr v1.11.0 // indirect + golang.org/x/crypto v0.25.0 // indirect golang.org/x/exp v0.0.0-20240531132922-fd00a4e0eefc // indirect golang.org/x/net v0.27.0 // indirect golang.org/x/sys v0.22.0 // indirect diff --git a/server/v2/go.sum b/server/v2/go.sum index 247c43d719ec..f82cb4e3b46d 100644 --- a/server/v2/go.sum +++ b/server/v2/go.sum @@ -1,8 +1,12 @@ cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= +cosmossdk.io/errors v1.0.1 h1:bzu+Kcr0kS/1DuPBtUFdWjzLqyUuCiyHjyJB6srBV/0= +cosmossdk.io/errors v1.0.1/go.mod h1:MeelVSZThMi4bEakzhhhE/CKqVv3nOJDA25bIqRDu/U= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/DataDog/datadog-go v3.2.0+incompatible h1:qSG2N4FghB1He/r2mFrWKCaL7dXCilEuNEeAn20fdD4= github.com/DataDog/datadog-go v3.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ= +github.com/DataDog/zstd v1.5.5 h1:oWf5W7GtOLgp6bciQYDmhHHjdhYkALu6S/5Ni9ZgSvQ= +github.com/DataDog/zstd v1.5.5/go.mod h1:g4AWEaM3yOg3HYfnJ3YIawPnVdXJh9QME85blwSAmyw= github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= @@ -18,6 +22,9 @@ github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs= github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= +github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= +github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI= +github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= github.com/circonus-labs/circonus-gometrics v2.3.1+incompatible/go.mod h1:nmEj6Dob7S7YxXgwXpfOuvO54S+tGdZdw9fuRZt25Ag= github.com/circonus-labs/circonusllhist v0.1.3/go.mod h1:kMXHVDlOchFAehlya5ePtbp5jckzBHf4XRpQvBOLI+I= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= @@ -28,7 +35,21 @@ github.com/cncf/xds/go v0.0.0-20210805033703-aa0b78936158/go.mod h1:eXthEFrGJvWH github.com/cncf/xds/go v0.0.0-20210922020428-25de7278fc84/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= github.com/cncf/xds/go v0.0.0-20211001041855-01bcc9b48dfe/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= github.com/cncf/xds/go v0.0.0-20211011173535-cb28da3451f1/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= +github.com/cockroachdb/datadriven v1.0.3-0.20230413201302-be42291fc80f h1:otljaYPt5hWxV3MUfO5dFPFiOXg9CyG5/kCfayTqsJ4= +github.com/cockroachdb/datadriven v1.0.3-0.20230413201302-be42291fc80f/go.mod h1:a9RdTaap04u637JoCzcUoIcDmvwSUtcUFtT/C3kJlTU= +github.com/cockroachdb/errors v1.11.1 h1:xSEW75zKaKCWzR3OfxXUxgrk/NtT4G1MiOv5lWZazG8= +github.com/cockroachdb/errors v1.11.1/go.mod h1:8MUxA3Gi6b25tYlFEBGLf+D8aISL+M4MIpiWMSNRfxw= +github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b h1:r6VH0faHjZeQy818SGhaone5OnYfxFR/+AzdY3sf5aE= +github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b/go.mod h1:Vz9DsVWQQhf3vs21MhPMZpMGSht7O/2vFW2xusFUVOs= +github.com/cockroachdb/pebble v1.1.0 h1:pcFh8CdCIt2kmEpK0OIatq67Ln9uGDYY3d5XnE0LJG4= +github.com/cockroachdb/pebble v1.1.0/go.mod h1:sEHm5NOXxyiAoKWhoFxT8xMgd/f3RA6qUqQ1BXKrh2E= +github.com/cockroachdb/redact v1.1.5 h1:u1PMllDkdFfPWaNGMyLD1+so+aq3uUItthCFqzwPJ30= +github.com/cockroachdb/redact v1.1.5/go.mod h1:BVNblN9mBWFyMyqK1k3AAiSxhvhfK2oOZZ2lK+dpvRg= +github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06 h1:zuQyyAKVxetITBuuhv3BI9cMrmStnpT18zmgmTxunpo= +github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06/go.mod h1:7nc4anLGjupUW/PeY5qiNYsdNXj7zopG+eqsS7To5IQ= github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= +github.com/cosmos/cosmos-db v1.0.2 h1:hwMjozuY1OlJs/uh6vddqnk9j7VamLv+0DBlbEXbAKs= +github.com/cosmos/cosmos-db v1.0.2/go.mod h1:Z8IXcFJ9PqKK6BIsVOB3QXtkKoqUOp1vRvPT39kOXEA= github.com/cosmos/cosmos-proto v1.0.0-beta.5 h1:eNcayDLpip+zVLRLYafhzLvQlSmyab+RC5W7ZfmxJLA= github.com/cosmos/cosmos-proto v1.0.0-beta.5/go.mod h1:hQGLpiIUloJBMdQMMWb/4wRApmI9hjHH05nefC0Ojec= github.com/cosmos/gogogateway v1.2.0 h1:Ae/OivNhp8DqBi/sh2A8a1D0y638GpL3tkmLQAiKxTE= @@ -36,11 +57,18 @@ github.com/cosmos/gogogateway v1.2.0/go.mod h1:iQpLkGWxYcnCdz5iAdLcRBSw3h7NXeOkZ github.com/cosmos/gogoproto v1.4.2/go.mod h1:cLxOsn1ljAHSV527CHOtaIP91kK6cCrZETRBrkzItWU= github.com/cosmos/gogoproto v1.5.0 h1:SDVwzEqZDDBoslaeZg+dGE55hdzHfgUA40pEanMh52o= github.com/cosmos/gogoproto v1.5.0/go.mod h1:iUM31aofn3ymidYG6bUR5ZFrk+Om8p5s754eMUcyp8I= +github.com/cosmos/iavl v1.2.0 h1:kVxTmjTh4k0Dh1VNL046v6BXqKziqMDzxo93oh3kOfM= +github.com/cosmos/iavl v1.2.0/go.mod h1:HidWWLVAtODJqFD6Hbne2Y0q3SdxByJepHUOeoH4LiI= +github.com/cosmos/ics23/go v0.10.0 h1:iXqLLgp2Lp+EdpIuwXTYIQU+AiHj9mOC2X9ab++bZDM= +github.com/cosmos/ics23/go v0.10.0/go.mod h1:ZfJSmng/TBNTBkFemHHHj5YY7VAU/MBU980F4VU1NG0= github.com/cpuguy83/go-md2man/v2 v2.0.4/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= +github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM= github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/emicklei/dot v1.6.1 h1:ujpDlBkkwgWUY+qPId5IwapRW/xEoligRSYjioR6DFI= +github.com/emicklei/dot v1.6.1/go.mod h1:DeV7GvQtIw4h2u73RKBkkFdvVAz0D9fzeJrgPW6gy/s= github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= @@ -53,14 +81,22 @@ github.com/fatih/color v1.15.0 h1:kOqh6YHBtK8aywxGerMG2Eq3H6Qgoqeo13Bk2Mv/nBs= github.com/fatih/color v1.15.0/go.mod h1:0h5ZqXfHYED7Bhv2ZJamyIOUej9KtShiJESRwBDUSsw= github.com/frankban/quicktest v1.14.6 h1:7Xjx+VpznH+oBnejlPUj8oUpdxnVs4f8XU8WnHkI4W8= github.com/frankban/quicktest v1.14.6/go.mod h1:4ptaffx2x8+WTWXmUCuVU6aPUX1/Mz7zb5vbUoiM6w0= +github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= +github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= +github.com/fsnotify/fsnotify v1.5.4/go.mod h1:OVB6XrOHzAwXMpEM7uPOzcehqUV2UqJxmVXmkdnm1bU= github.com/fsnotify/fsnotify v1.7.0 h1:8JEhPFa5W2WU7YfeZzPNqzMP6Lwt7L2715Ggo0nosvA= github.com/fsnotify/fsnotify v1.7.0/go.mod h1:40Bi/Hjc2AVfZrqy+aj+yEI+/bRxZnMJyTJwOpGvigM= +github.com/getsentry/sentry-go v0.27.0 h1:Pv98CIbtB3LkMWmXi4Joa5OOcwbmnX88sF5qbK3r3Ps= +github.com/getsentry/sentry-go v0.27.0/go.mod h1:lc76E2QywIyW8WuBnwl8Lc4bkmQH4+w1gwTf25trprY= github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= +github.com/go-errors/errors v1.4.2 h1:J6MZopCL4uSllY1OfXM374weqZFFItUbrImctkmUxIA= +github.com/go-errors/errors v1.4.2/go.mod h1:sIVyrIiJhuEF+Pj9Ebtd6P/rEYROXFi3BopGUQ5a5Og= github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE= github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk= github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= +github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0/go.mod h1:fyg7847qk6SyHyPtNmDHnmrv/HOrqktSC+C9fM+CJOE= github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= github.com/gogo/googleapis v1.4.1-0.20201022092350-68b0159b7869/go.mod h1:5YRNX2z1oM5gXdAkurHa942MDgEJyk02w4OecKY87+c= github.com/gogo/googleapis v1.4.1 h1:1Yx4Myt7BxzvUr5ldGSbwYiZG6t9wGBZ+8/fX3Wvtq0= @@ -71,6 +107,8 @@ github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= +github.com/golang/mock v1.6.0 h1:ErTB+efbowRARo13NNdxyJji2egdxLGQhRaY+DUumQc= +github.com/golang/mock v1.6.0/go.mod h1:p6yTPP+5HYm5mzsMV8JkE6ZKdX+/wYM6Hr+LicevLPs= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= @@ -87,6 +125,10 @@ github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaS github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= +github.com/golang/snappy v0.0.4 h1:yAGX7huGHXlcLOEtBnF4w7FQwA26wojNCwOYAEhLjQM= +github.com/golang/snappy v0.0.4/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= +github.com/google/btree v1.1.2 h1:xf4v41cLI2Z6FxbKm+8Bu+m8ifhj15JuZ9sa0jZCMUU= +github.com/google/btree v1.1.2/go.mod h1:qOPhT0dTNdNzV6Z/lhRX0YXUafgPLFUh+gZMl761Gm4= github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= @@ -97,6 +139,7 @@ github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/ github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= +github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/gorilla/mux v1.8.1 h1:TuBL49tXwgrFYWhqrNgrUNEY92u81SPhu7sTdzQEiWY= github.com/gorilla/mux v1.8.1/go.mod h1:AKf9I4AEqPTmMytcMc0KkNouC66V3BtZ4qD5fmWSiMQ= @@ -123,6 +166,8 @@ github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4= github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= github.com/hashicorp/yamux v0.1.1 h1:yrQxtgseBDrq9Y652vSRDvsKCJKOUD+GzTS4Y0Y8pvE= github.com/hashicorp/yamux v0.1.1/go.mod h1:CtWFDAQgb7dxtzFs4tWbplKIe2jSi3+5vKbgIO0SLnQ= +github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= +github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8= github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= github.com/jhump/protoreflect v1.15.3 h1:6SFRuqU45u9hIZPJAoZ8c28T3nK64BNdp9w6jFonzls= @@ -133,6 +178,8 @@ github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7V github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQLJ+jE2L00= github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= +github.com/klauspost/compress v1.17.7 h1:ehO88t2UGzQK66LMdE8tibEd1ErmzZjNEqWkjLAKQQg= +github.com/klauspost/compress v1.17.7/go.mod h1:Di0epgTjJY877eYKx5yC51cX2A2Vl2ibi7bDH9ttBbw= github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= @@ -142,6 +189,8 @@ github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= +github.com/linxGnu/grocksdb v1.8.14 h1:HTgyYalNwBSG/1qCQUIott44wU5b2Y9Kr3z7SK5OfGQ= +github.com/linxGnu/grocksdb v1.8.14/go.mod h1:QYiYypR2d4v63Wj1adOOfzglnoII0gLj3PNh4fZkcFA= github.com/magiconair/properties v1.8.7 h1:IeQXZAiQcpL9mgcAe1Nu6cX9LLw6ExEHKjN0VQdvPDY= github.com/magiconair/properties v1.8.7/go.mod h1:Dhd985XPs7jluiymwWYZ0G4Z61jb3vdS329zhj2hYo0= github.com/mattn/go-colorable v0.1.9/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= @@ -154,6 +203,8 @@ github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/ github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= +github.com/mattn/go-sqlite3 v1.14.22 h1:2gZY6PC6kBnID23Tichd1K+Z0oS6nE/XwU+Vz/5o4kU= +github.com/mattn/go-sqlite3 v1.14.22/go.mod h1:Uh1q+B4BYcTPb+yiD3kU8Ct7aC0hY9fxUwlHK0RXw+Y= github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= github.com/mitchellh/go-testing-interface v1.14.1 h1:jrgshOhYAUVNMAJiKbEu7EqAwgJJ2JqpQmpLJOu07cU= github.com/mitchellh/go-testing-interface v1.14.1/go.mod h1:gfgS7OtZj6MA4U1UrDRp04twqAjfvlZyCfX3sDjEym8= @@ -166,12 +217,30 @@ github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3Rllmb github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA= github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ= github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= +github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A= +github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE= +github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU= github.com/oklog/run v1.1.0 h1:GEenZ1cK0+q0+wsJew9qUg/DyD8k3JzYsZAi5gYi2mA= github.com/oklog/run v1.1.0/go.mod h1:sVPdnTZT1zYwAJeCMu2Th4T21pA3FPOQRfWjQlk7DVU= +github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= +github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk= +github.com/onsi/ginkgo v1.16.4/go.mod h1:dX+/inL/fNMqNlz0e9LfyB9TswhZpCVdJM/Z6Vvnwo0= +github.com/onsi/ginkgo v1.16.5 h1:8xi0RTUf59SOSfEtZMvwTvXYMzG4gV23XVHOZiXNtnE= +github.com/onsi/ginkgo v1.16.5/go.mod h1:+E8gABHa3K6zRBolWtd+ROzc/U5bkGt0FwiG042wbpU= +github.com/onsi/ginkgo/v2 v2.1.3/go.mod h1:vw5CSIxN1JObi/U8gcbwft7ZxR2dgaR70JSE3/PpL4c= +github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY= +github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo= +github.com/onsi/gomega v1.17.0/go.mod h1:HnhC7FXeEQY45zxNK3PPoIUhzk/80Xly9PcubAlGdZY= +github.com/onsi/gomega v1.19.0/go.mod h1:LY+I3pBVzYsTBU1AnDwOSxaYi9WoWiqgwooUqq9yPro= +github.com/onsi/gomega v1.26.0 h1:03cDLK28U6hWvCAns6NeydX3zIm4SF3ci69ulidS32Q= +github.com/onsi/gomega v1.26.0/go.mod h1:r+zV744Re+DiYCIPRlYOTxn0YkOLcAnW8k1xXdMPGhM= github.com/pascaldekloe/goe v0.1.0 h1:cBOtyMzM9HTpWjXfbbunk26uA6nG3a8n06Wieeh0MwY= github.com/pascaldekloe/goe v0.1.0/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= github.com/pelletier/go-toml/v2 v2.2.2 h1:aYUidT7k73Pcl9nb2gScu7NSrKCSHIDE89b3+6Wq+LM= github.com/pelletier/go-toml/v2 v2.2.2/go.mod h1:1t835xjRzz80PqgE6HHgN2JOsmgYu/h4qDAS4n929Rs= +github.com/pingcap/errors v0.11.4 h1:lFuQV/oaUMGcD2tqt+01ROSmJs75VG1ToEOkZIZ4nE4= +github.com/pingcap/errors v0.11.4/go.mod h1:Oi8TUi2kEtXXLMJk9l1cGmz20kV3TaQ0usTwv5KuLY8= +github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA= github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= @@ -200,6 +269,7 @@ github.com/prometheus/procfs v0.0.8/go.mod h1:7Qr8sr6344vo1JqZ6HhLceV9o3AJ1Ff+Gx github.com/prometheus/procfs v0.15.1 h1:YagwOFzUgYfKKHX6Dr+sHT7km/hxC76UB0learggepc= github.com/prometheus/procfs v0.15.1/go.mod h1:fB45yRUv8NstnjriLhBQLuOUt+WW4BsoGhij/e3PBqk= github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= +github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs= github.com/rogpeppe/go-internal v1.12.0 h1:exVL4IDcn6na9z1rAb56Vxr+CgyK3nn3O+epU5NdKM8= github.com/rogpeppe/go-internal v1.12.0/go.mod h1:E+RYuTGaKKdloAfM02xzb0FW3Paa99yedzYV+kq4uf4= github.com/rs/xid v1.5.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg= @@ -243,6 +313,8 @@ github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsT github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/subosito/gotenv v1.6.0 h1:9NlTDc1FTs4qu0DDq7AEtTPNw6SVm7uBMsUCUjABIf8= github.com/subosito/gotenv v1.6.0/go.mod h1:Dk4QP5c2W3ibzajGcXpNraDfq2IrhjMIvMSWPKKo0FU= +github.com/syndtr/goleveldb v1.0.1-0.20220721030215-126854af5e6d h1:vfofYNRScrDdvS342BElfbETmL1Aiz3i2t0zfRj16Hs= +github.com/syndtr/goleveldb v1.0.1-0.20220721030215-126854af5e6d/go.mod h1:RRCYJbIwD5jmqPI9XoAFR0OcDxqUctll6zUj/+B4S48= github.com/tidwall/btree v1.7.0 h1:L1fkJH/AuEh5zBnnBbmTwQ5Lt+bRJ5A8EWecslvo9iI= github.com/tidwall/btree v1.7.0/go.mod h1:twD9XRA5jj9VUQGELzDO4HPQTNJsoWWfYEL+EUQ2cKY= github.com/tv42/httpunix v0.0.0-20150427012821-b75d8614f926/go.mod h1:9ESjWnEqriFuLhtthL60Sar/7RFoluCcXsuvEwTV5KM= @@ -255,6 +327,8 @@ golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnf golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/crypto v0.25.0 h1:ypSNr+bnYL2YhwoMt2zPxHFmbAN1KZs/njMG3hxUp30= +golang.org/x/crypto v0.25.0/go.mod h1:T+wALwcMOSE0kXgUAnPAHqTLW+XHgcELELW8VaDgm/M= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20240531132922-fd00a4e0eefc h1:O9NuF4s+E/PvMIy+9IUZB9znFwUIXEWSstNjek6VpVg= golang.org/x/exp v0.0.0-20240531132922-fd00a4e0eefc/go.mod h1:XtvwrStGgqGPLc4cjQfWqZHG1YFdYs6swckp8vpsjnc= @@ -265,6 +339,7 @@ golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -273,10 +348,13 @@ golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= +golang.org/x/net v0.0.0-20210428140749-89ef3d95e781/go.mod h1:OJAsFXCWl8Ukc7SiCT/9KSuxbyM7479/AVlXFRxuMCk= golang.org/x/net v0.0.0-20220225172249-27dd8689420f/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= +golang.org/x/net v0.0.0-20220607020251-c690dde0001d/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= golang.org/x/net v0.27.0 h1:5K3Njcw06/l2y9vpGCSdcxWOYHOUk3dVNGDXN+FvAys= golang.org/x/net v0.27.0/go.mod h1:dDi0PyhWNoiUOrAS8uXv/vnScO4wnHQO4mj9fn/RytE= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= @@ -291,25 +369,34 @@ golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M= golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200122134326-e047566fdf82/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210112080510-489259a85091/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220315194320-039c03cc5b86/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220412211240-33da011f77ad/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220503163025-988cb79eb6c6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= @@ -320,6 +407,7 @@ golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuX golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4= golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI= @@ -331,11 +419,13 @@ golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3 golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= +golang.org/x/tools v0.0.0-20201224043029-2b0845dc783e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20220517211312-f3a8303e98df/go.mod h1:K8+ghG5WaK9qNqU5K3HdILfMLy1f3aNYFI/wnl100a8= google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= @@ -379,13 +469,18 @@ gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8 gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= +gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= gopkg.in/ini.v1 v1.67.0 h1:Dgnx+6+nfE+IfzjUEISNeydPJh9AXNNsWbGP9KzCsOA= gopkg.in/ini.v1 v1.67.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= +gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ= +gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.3/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.5/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/server/v2/store/commands.go b/server/v2/store/commands.go new file mode 100644 index 000000000000..e1c8a20dfb60 --- /dev/null +++ b/server/v2/store/commands.go @@ -0,0 +1,163 @@ +package store + +import ( + "fmt" + "os" + "path/filepath" + "strings" + + "github.com/spf13/cobra" + "github.com/spf13/viper" + + "cosmossdk.io/log" + serverv2 "cosmossdk.io/server/v2" + storev2 "cosmossdk.io/store/v2" + "cosmossdk.io/store/v2/db" + "cosmossdk.io/store/v2/root" +) + +// QueryBlockResultsCmd implements the default command for a BlockResults query. +func (s *StoreComponent[T]) PrunesCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: "prune [pruning-method]", + Short: "Prune app history states by keeping the recent heights and deleting old heights", + Long: `Prune app history states by keeping the recent heights and deleting old heights. +The pruning option is provided via the 'pruning' argument or alternatively with '--pruning-keep-recent' + +- default: the last 362880 states are kept +- nothing: all historic states will be saved, nothing will be deleted (i.e. archiving node) +- everything: 2 latest states will be kept +- custom: allow pruning options to be manually specified through 'pruning-keep-recent' + +Note: When the --app-db-backend flag is not specified, the default backend type is 'goleveldb'. +Supported app-db-backend types include 'goleveldb', 'rocksdb', 'pebbledb'.`, + Example: fmt.Sprintf("%s prune custom --pruning-keep-recent 100 --app-db-backend 'goleveldb'", ""), + Args: cobra.RangeArgs(0, 1), + RunE: func(cmd *cobra.Command, args []string) error { + // bind flags to the Context's Viper so we can get pruning options. + vp := serverv2.GetViperFromCmd(cmd) + if err := vp.BindPFlags(cmd.Flags()); err != nil { + return err + } + if err := vp.BindPFlags(cmd.PersistentFlags()); err != nil { + return err + } + + logger := log.NewLogger(cmd.OutOrStdout()) + home, err := cmd.Flags().GetString(serverv2.FlagHome) + if err != nil { + return err + } + + rootStore, keepRecent, err := createRootStore(cmd, home, vp, logger) + if err != nil { + return fmt.Errorf("can not create root store %w", err) + } + + latestHeight, err := rootStore.GetLatestVersion() + if err != nil { + return err + } + + // valid heights should be greater than 0. + if latestHeight <= 0 { + return fmt.Errorf("the database has no valid heights to prune, the latest height: %v", latestHeight) + } + + upTo := latestHeight - keepRecent + cmd.Printf("pruning heights up to %v\n", upTo) + + err = rootStore.Prune(latestHeight) + if err != nil { + return err + } + + cmd.Println("successfully pruned the application root multi stores") + return nil + }, + } + + cmd.Flags().String(FlagAppDBBackend, "", "The type of database for application and snapshots databases") + cmd.Flags().Uint64(FlagPruningKeepRecent, 0, "Number of recent heights to keep on disk (ignored if pruning is not 'custom')") + + return cmd +} + +func createRootStore(cmd *cobra.Command, rootDir string, v *viper.Viper, logger log.Logger) (storev2.RootStore, uint64, error) { + tempViper := v + + // handle FlagAppDBBackend + var dbType db.DBType + if cmd.Flags().Changed(FlagAppDBBackend) { + dbStr, err := cmd.Flags().GetString(FlagAppDBBackend) + if err != nil { + return nil, 0, err + } + dbType = db.DBType(dbStr) + } else { + dbType = db.DBType(v.GetString("store.app-db-backend")) + } + scRawDb, err := db.NewDB(dbType, "application", filepath.Join(rootDir, "data"), nil) + if err != nil { + panic(err) + } + + // handle KeepRecent & Interval flags + if cmd.Flags().Changed(FlagPruningKeepRecent) { + keepRecent, err := cmd.Flags().GetUint64(FlagPruningKeepRecent) + if err != nil { + return nil, 0, err + } + + // viper has an issue that we could not override subitem then Unmarshal key + // so we can not do viper.Set() as comment below + // https://github.com/spf13/viper/issues/1106 + // Do it by a hacky: overwrite app.toml file then read config again. + + // v.Set("store.options.sc-pruning-option.keep-recent", keepRecent) // entry that read from app.toml + // v.Set("store.options.ss-pruning-option.keep-recent", keepRecent) + + err = overrideKeepRecent(filepath.Join(rootDir, "config"), keepRecent) + if err != nil { + return nil, 0, err + } + + tempViper, err = serverv2.ReadConfig(filepath.Join(rootDir, "config")) + if err != nil { + return nil, 0, err + } + } + + storeOpts := root.DefaultStoreOptions() + if v != nil { + if err := v.Sub("store.options").Unmarshal(&storeOpts); err != nil { + return nil, 0, fmt.Errorf("failed to store options: %w", err) + } + } + + store, err := root.CreateRootStore(&root.FactoryOptions{ + Logger: logger, + RootDir: rootDir, + Options: storeOpts, + SCRawDB: scRawDb, + }) + + return store, tempViper.GetUint64("store.options.sc-pruning-option.keep-recent"), err +} + +func overrideKeepRecent(configPath string, keepRecent uint64) error { + bz, err := os.ReadFile(filepath.Join(configPath, "app.toml")) + if err != nil { + return err + } + lines := strings.Split(string(bz), "\n") + + for i, line := range lines { + if strings.Contains(line, "keep-recent") { + lines[i] = fmt.Sprintf("keep-recent = %d", keepRecent) + } + } + output := strings.Join(lines, "\n") + + return os.WriteFile(filepath.Join(configPath, "app.toml"), []byte(output), 0o600) +} diff --git a/server/v2/store/config.go b/server/v2/store/config.go new file mode 100644 index 000000000000..457bfa9383cb --- /dev/null +++ b/server/v2/store/config.go @@ -0,0 +1,17 @@ +package store + +import ( + "cosmossdk.io/store/v2/root" +) + +func DefaultConfig() *Config { + return &Config{ + AppDBBackend: "goleveldb", + Options: root.DefaultStoreOptions(), + } +} + +type Config struct { + AppDBBackend string `mapstructure:"app-db-backend" toml:"app-db-backend" comment:"The type of database for application and snapshots databases."` + Options root.Options `mapstructure:"options" toml:"options"` +} diff --git a/server/v2/store/flags.go b/server/v2/store/flags.go new file mode 100644 index 000000000000..9bf1af5282f4 --- /dev/null +++ b/server/v2/store/flags.go @@ -0,0 +1,6 @@ +package store + +const ( + FlagAppDBBackend = "app-db-backend" + FlagPruningKeepRecent = "keep-recent" +) diff --git a/server/v2/store/server.go b/server/v2/store/server.go new file mode 100644 index 000000000000..2adaa8b7ef8e --- /dev/null +++ b/server/v2/store/server.go @@ -0,0 +1,76 @@ +package store + +import ( + "context" + "fmt" + + "github.com/spf13/cobra" + "github.com/spf13/viper" + + "cosmossdk.io/core/log" + "cosmossdk.io/core/transaction" + serverv2 "cosmossdk.io/server/v2" +) + +// StoreComponent manages store config +// and contains prune & snapshot commands +type StoreComponent[T transaction.Tx] struct { + config *Config +} + +func New[T transaction.Tx]() *StoreComponent[T] { + return &StoreComponent[T]{} +} + +func (s *StoreComponent[T]) Init(appI serverv2.AppI[T], v *viper.Viper, logger log.Logger) error { + cfg := DefaultConfig() + if v != nil { + if err := v.Sub(s.Name()).Unmarshal(&cfg); err != nil { + return fmt.Errorf("failed to unmarshal config: %w", err) + } + } + s.config = cfg + return nil +} + +func (s *StoreComponent[T]) Name() string { + return "store" +} + +func (s *StoreComponent[T]) Start(ctx context.Context) error { + return nil +} + +func (s *StoreComponent[T]) Stop(ctx context.Context) error { + return nil +} + +func (s *StoreComponent[T]) GetCommands() []*cobra.Command { + return []*cobra.Command{ + s.PrunesCmd(), + } +} + +func (s *StoreComponent[T]) GetTxs() []*cobra.Command { + return nil +} + +func (s *StoreComponent[T]) GetQueries() []*cobra.Command { + return nil +} + +func (s *StoreComponent[T]) CLICommands() serverv2.CLIConfig { + return serverv2.CLIConfig{ + Commands: []*cobra.Command{ + s.PrunesCmd(), + }, + } +} + +func (g *StoreComponent[T]) Config() any { + if g.config == nil || g.config == (&Config{}) { + return DefaultConfig() + } + + return g.config +} diff --git a/simapp/v2/app_di.go b/simapp/v2/app_di.go index 5f4b2455bc8d..7219193935f7 100644 --- a/simapp/v2/app_di.go +++ b/simapp/v2/app_di.go @@ -2,7 +2,6 @@ package simapp import ( _ "embed" - "path/filepath" "github.com/spf13/viper" @@ -14,10 +13,6 @@ import ( "cosmossdk.io/depinject" "cosmossdk.io/runtime/v2" serverv2 "cosmossdk.io/server/v2" - "cosmossdk.io/store/v2" - "cosmossdk.io/store/v2/commitment/iavl" - "cosmossdk.io/store/v2/db" - "cosmossdk.io/store/v2/root" "cosmossdk.io/x/accounts" authkeeper "cosmossdk.io/x/auth/keeper" authzkeeper "cosmossdk.io/x/authz/keeper" @@ -97,10 +92,6 @@ func NewSimApp[T transaction.Tx]( viper *viper.Viper, ) *SimApp[T] { viper.Set(serverv2.FlagHome, DefaultNodeHome) // TODO possibly set earlier when viper is created - scRawDb, err := db.NewGoLevelDB("application", filepath.Join(DefaultNodeHome, "data"), nil) - if err != nil { - panic(err) - } var ( app = &SimApp[T]{} appBuilder *runtime.AppBuilder[T] @@ -110,21 +101,6 @@ func NewSimApp[T transaction.Tx]( AppConfig(), depinject.Supply( logger, - &root.FactoryOptions{ - Logger: logger, - RootDir: DefaultNodeHome, - SSType: 0, - SCType: 0, - SCPruningOption: &store.PruningOption{ - KeepRecent: 0, - Interval: 0, - }, - IavlConfig: &iavl.Config{ - CacheSize: 100_000, - SkipFastStorageUpgrade: true, - }, - SCRawDB: scRawDb, - }, viper, // ADVANCED CONFIGURATION @@ -206,6 +182,7 @@ func NewSimApp[T transaction.Tx]( panic(err) } + var err error app.App, err = appBuilder.Build() if err != nil { panic(err) diff --git a/simapp/v2/go.mod b/simapp/v2/go.mod index 535cf5c7ac0a..4953ca17b529 100644 --- a/simapp/v2/go.mod +++ b/simapp/v2/go.mod @@ -10,9 +10,9 @@ require ( cosmossdk.io/log v1.3.1 cosmossdk.io/math v1.3.0 cosmossdk.io/runtime/v2 v2.0.0-00010101000000-000000000000 - cosmossdk.io/server/v2 v2.0.0-00010101000000-000000000000 + cosmossdk.io/server/v2 v2.0.0-20240718121635-a877e3e8048a cosmossdk.io/server/v2/cometbft v0.0.0-00010101000000-000000000000 - cosmossdk.io/store/v2 v2.0.0 + cosmossdk.io/store/v2 v2.0.0 // indirect cosmossdk.io/tools/confix v0.0.0-00010101000000-000000000000 cosmossdk.io/x/accounts v0.0.0-20240226161501-23359a0b6d91 cosmossdk.io/x/auth v0.0.0-00010101000000-000000000000 diff --git a/simapp/v2/simdv2/cmd/commands.go b/simapp/v2/simdv2/cmd/commands.go index fd32461c56ce..d1462e58768c 100644 --- a/simapp/v2/simdv2/cmd/commands.go +++ b/simapp/v2/simdv2/cmd/commands.go @@ -16,6 +16,7 @@ import ( serverv2 "cosmossdk.io/server/v2" "cosmossdk.io/server/v2/api/grpc" "cosmossdk.io/server/v2/cometbft" + "cosmossdk.io/server/v2/store" "cosmossdk.io/simapp/v2" confixcmd "cosmossdk.io/tools/confix/cmd" authcmd "cosmossdk.io/x/auth/client/cli" @@ -76,6 +77,7 @@ func initRootCmd[T transaction.Tx]( logger, cometbft.New(&genericTxDecoder[T]{txConfig}, cometbft.DefaultServerOptions[T]()), grpc.New[T](), + store.New[T](), ); err != nil { panic(err) } diff --git a/store/v2/commitment/iavl/config.go b/store/v2/commitment/iavl/config.go index 7e386b3a46c4..d4b9b3bd0cbb 100644 --- a/store/v2/commitment/iavl/config.go +++ b/store/v2/commitment/iavl/config.go @@ -2,8 +2,8 @@ package iavl // Config is the configuration for the IAVL tree. type Config struct { - CacheSize int `mapstructure:"cache_size"` - SkipFastStorageUpgrade bool `mapstructure:"skip_fast_storage_upgrade"` + CacheSize int `mapstructure:"cache_size" toml:"cache_size" comment:"CacheSize set the size of the iavl tree cache."` + SkipFastStorageUpgrade bool `mapstructure:"skip_fast_storage_upgrade" toml:"skip_fast_storage_upgrade" comment:"If true, the tree will work like no fast storage and always not upgrade fast storage."` } // DefaultConfig returns the default configuration for the IAVL tree. diff --git a/store/v2/go.mod b/store/v2/go.mod index aea6c0d464f7..6bfc165ca32e 100644 --- a/store/v2/go.mod +++ b/store/v2/go.mod @@ -37,7 +37,7 @@ require ( github.com/gogo/protobuf v1.3.2 // indirect github.com/golang/snappy v0.0.4 // indirect github.com/google/go-cmp v0.6.0 // indirect - github.com/hashicorp/go-immutable-radix v1.0.0 // indirect + github.com/hashicorp/go-immutable-radix v1.3.1 // indirect github.com/hashicorp/go-uuid v1.0.1 // indirect github.com/hashicorp/golang-lru v1.0.2 // indirect github.com/klauspost/compress v1.17.7 // indirect @@ -55,7 +55,7 @@ require ( github.com/rogpeppe/go-internal v1.12.0 // indirect github.com/rs/zerolog v1.33.0 // indirect github.com/tidwall/btree v1.7.0 // indirect - golang.org/x/crypto v0.24.0 // indirect + golang.org/x/crypto v0.25.0 // indirect golang.org/x/exp v0.0.0-20240314144324-c7f7c6466f7f // indirect golang.org/x/sys v0.22.0 // indirect golang.org/x/text v0.16.0 // indirect diff --git a/store/v2/go.sum b/store/v2/go.sum index 66d125306c7a..ac521df72272 100644 --- a/store/v2/go.sum +++ b/store/v2/go.sum @@ -96,8 +96,9 @@ github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeN github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= github.com/hashicorp/go-cleanhttp v0.5.0/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= -github.com/hashicorp/go-immutable-radix v1.0.0 h1:AKDB1HM5PWEA7i4nhcpwOrO2byshxBjXVn/J/3+z5/0= github.com/hashicorp/go-immutable-radix v1.0.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60= +github.com/hashicorp/go-immutable-radix v1.3.1 h1:DKHmCUm2hRBK510BaiZlwvpD40f8bJFeZnpfm2KLowc= +github.com/hashicorp/go-immutable-radix v1.3.1/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60= github.com/hashicorp/go-metrics v0.5.3 h1:M5uADWMOGCTUNU1YuC4hfknOeHNaX54LDm4oYSucoNE= github.com/hashicorp/go-metrics v0.5.3/go.mod h1:KEjodfebIOuBYSAe/bHTm+HChmKSxAOXPBieMLYozDE= github.com/hashicorp/go-retryablehttp v0.5.3/go.mod h1:9B5zBasrRhHXnJnui7y6sL7es7NDiJgTc6Er0maI1Xs= @@ -219,8 +220,8 @@ golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnf golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.24.0 h1:mnl8DM0o513X8fdIkmyFE/5hTYxbwYOjDS/+rK6qpRI= -golang.org/x/crypto v0.24.0/go.mod h1:Z1PMYSOR5nyMcyAVAIQSKCDwalqy85Aqn1x3Ws4L5DM= +golang.org/x/crypto v0.25.0 h1:ypSNr+bnYL2YhwoMt2zPxHFmbAN1KZs/njMG3hxUp30= +golang.org/x/crypto v0.25.0/go.mod h1:T+wALwcMOSE0kXgUAnPAHqTLW+XHgcELELW8VaDgm/M= golang.org/x/exp v0.0.0-20240314144324-c7f7c6466f7f h1:3CW0unweImhOzd5FmYuRsD4Y4oQFKZIjAnKbjV4WIrw= golang.org/x/exp v0.0.0-20240314144324-c7f7c6466f7f/go.mod h1:CxmFvTBINI24O/j8iY7H1xHzx2i4OsyguNBmN/uPtqc= golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= diff --git a/store/v2/options.go b/store/v2/options.go index 9c20d8494230..f87475e4a6d2 100644 --- a/store/v2/options.go +++ b/store/v2/options.go @@ -18,13 +18,14 @@ const ( ) // PruningOption defines the pruning configuration. +// app.toml config options type PruningOption struct { // KeepRecent sets the number of recent versions to keep. - KeepRecent uint64 + KeepRecent uint64 `mapstructure:"keep-recent" toml:"keep-recent" comment:"Number of recent heights to keep on disk."` // Interval sets the number of how often to prune. // If set to 0, no pruning will be done. - Interval uint64 + Interval uint64 `mapstructure:"interval" toml:"interval" comment:"Height interval at which pruned heights are removed from disk."` } // NewPruningOption returns a new PruningOption instance based on the given pruning strategy. diff --git a/store/v2/root/factory.go b/store/v2/root/factory.go index 7139f48abf87..563e439815bc 100644 --- a/store/v2/root/factory.go +++ b/store/v2/root/factory.go @@ -32,16 +32,40 @@ const ( SCTypeIavlV2 SCType = 1 ) +// app.toml config options +type Options struct { + SSType SSType `mapstructure:"ss-type" toml:"ss-type" comment:"State storage database type. Currently we support: 0 for SQLite, 1 for Pebble"` + SCType SCType `mapstructure:"sc-type" toml:"sc-type" comment:"State commitment database type. Currently we support:0 for iavl, 1 for iavl v2"` + SSPruningOption *store.PruningOption `mapstructure:"ss-pruning-option" toml:"ss-pruning-option" comment:"Pruning options for state storage"` + SCPruningOption *store.PruningOption `mapstructure:"sc-pruning-option" toml:"sc-pruning-option" comment:"Pruning options for state commitment"` + IavlConfig *iavl.Config `mapstructure:"iavl-config" toml:"iavl-config"` +} + type FactoryOptions struct { - Logger log.Logger - RootDir string - SSType SSType - SCType SCType - SSPruningOption *store.PruningOption - SCPruningOption *store.PruningOption - IavlConfig *iavl.Config - StoreKeys []string - SCRawDB corestore.KVStoreWithBatch + Logger log.Logger + RootDir string + Options Options + StoreKeys []string + SCRawDB corestore.KVStoreWithBatch +} + +func DefaultStoreOptions() Options { + return Options{ + SSType: 0, + SCType: 0, + SCPruningOption: &store.PruningOption{ + KeepRecent: 2, + Interval: 1, + }, + SSPruningOption: &store.PruningOption{ + KeepRecent: 2, + Interval: 1, + }, + IavlConfig: &iavl.Config{ + CacheSize: 100_000, + SkipFastStorageUpgrade: true, + }, + } } // CreateRootStore is a convenience function to create a root store based on the @@ -62,7 +86,8 @@ func CreateRootStore(opts *FactoryOptions) (store.RootStore, error) { } ) - switch opts.SSType { + storeOpts := opts.Options + switch storeOpts.SSType { case SSTypeSQLite: dir := fmt.Sprintf("%s/data/ss/sqlite", opts.RootDir) if err = ensureDir(dir); err != nil { @@ -107,9 +132,9 @@ func CreateRootStore(opts *FactoryOptions) (store.RootStore, error) { if internal.IsMemoryStoreKey(key) { trees[key] = mem.New() } else { - switch opts.SCType { + switch storeOpts.SCType { case SCTypeIavl: - trees[key] = iavl.NewIavlTree(db.NewPrefixDB(opts.SCRawDB, []byte(key)), opts.Logger, opts.IavlConfig) + trees[key] = iavl.NewIavlTree(db.NewPrefixDB(opts.SCRawDB, []byte(key)), opts.Logger, storeOpts.IavlConfig) case SCTypeIavlV2: return nil, errors.New("iavl v2 not supported") } @@ -120,7 +145,7 @@ func CreateRootStore(opts *FactoryOptions) (store.RootStore, error) { return nil, err } - pm := pruning.NewManager(sc, ss, opts.SCPruningOption, opts.SSPruningOption) + pm := pruning.NewManager(sc, ss, storeOpts.SCPruningOption, storeOpts.SSPruningOption) return New(opts.Logger, ss, sc, pm, nil, nil) } diff --git a/store/v2/root/store.go b/store/v2/root/store.go index 997f9d0f485e..c9c480557f48 100644 --- a/store/v2/root/store.go +++ b/store/v2/root/store.go @@ -467,3 +467,7 @@ func (s *Store) commitSC() error { return nil } + +func (s *Store) Prune(version uint64) error { + return s.pruningManager.Prune(version) +} diff --git a/store/v2/store.go b/store/v2/store.go index f6af274220d1..71a3cc48bcad 100644 --- a/store/v2/store.go +++ b/store/v2/store.go @@ -67,6 +67,8 @@ type RootStore interface { // SetMetrics sets the telemetry handler on the RootStore. SetMetrics(m metrics.Metrics) + Prune(version uint64) error + io.Closer } From 7d892e543227cd894f03d464887c25db6558400d Mon Sep 17 00:00:00 2001 From: Aaron Craelius Date: Tue, 23 Jul 2024 22:02:00 +0200 Subject: [PATCH 33/50] refactor(schema)!: collect all types in ModuleSchema (#21036) --- schema/decoding/decoding_test.go | 34 +++- schema/decoding/resolver_test.go | 30 ++- schema/enum.go | 30 +-- schema/module_schema.go | 110 ++++++++++- schema/module_schema_test.go | 327 +++++++++++++++++++++---------- schema/object_type.go | 16 +- schema/type.go | 7 + 7 files changed, 390 insertions(+), 164 deletions(-) create mode 100644 schema/type.go diff --git a/schema/decoding/decoding_test.go b/schema/decoding/decoding_test.go index d4308390d29c..5f6872af593a 100644 --- a/schema/decoding/decoding_test.go +++ b/schema/decoding/decoding_test.go @@ -366,8 +366,9 @@ func (e exampleBankModule) subBalance(acct, denom string, amount uint64) error { return nil } -var exampleBankSchema = schema.ModuleSchema{ - ObjectTypes: []schema.ObjectType{ +func init() { + var err error + exampleBankSchema, err = schema.NewModuleSchema([]schema.ObjectType{ { Name: "balances", KeyFields: []schema.Field{ @@ -387,9 +388,14 @@ var exampleBankSchema = schema.ModuleSchema{ }, }, }, - }, + }) + if err != nil { + panic(err) + } } +var exampleBankSchema schema.ModuleSchema + func (e exampleBankModule) ModuleCodec() (schema.ModuleCodec, error) { return schema.ModuleCodec{ Schema: exampleBankSchema, @@ -426,17 +432,25 @@ type oneValueModule struct { store *testStore } -var oneValueModSchema = schema.ModuleSchema{ - ObjectTypes: []schema.ObjectType{ - { - Name: "item", - ValueFields: []schema.Field{ - {Name: "value", Kind: schema.StringKind}, +func init() { + var err error + oneValueModSchema, err = schema.NewModuleSchema( + []schema.ObjectType{ + { + Name: "item", + ValueFields: []schema.Field{ + {Name: "value", Kind: schema.StringKind}, + }, }, }, - }, + ) + if err != nil { + panic(err) + } } +var oneValueModSchema schema.ModuleSchema + func (i oneValueModule) ModuleCodec() (schema.ModuleCodec, error) { return schema.ModuleCodec{ Schema: oneValueModSchema, diff --git a/schema/decoding/resolver_test.go b/schema/decoding/resolver_test.go index f5caf287ca5f..a5e9fa33c947 100644 --- a/schema/decoding/resolver_test.go +++ b/schema/decoding/resolver_test.go @@ -10,16 +10,24 @@ import ( type modA struct{} func (m modA) ModuleCodec() (schema.ModuleCodec, error) { + modSchema, err := schema.NewModuleSchema([]schema.ObjectType{{Name: "A", KeyFields: []schema.Field{{Name: "field1", Kind: schema.StringKind}}}}) + if err != nil { + return schema.ModuleCodec{}, err + } return schema.ModuleCodec{ - Schema: schema.ModuleSchema{ObjectTypes: []schema.ObjectType{{Name: "A"}}}, + Schema: modSchema, }, nil } type modB struct{} func (m modB) ModuleCodec() (schema.ModuleCodec, error) { + modSchema, err := schema.NewModuleSchema([]schema.ObjectType{{Name: "B", KeyFields: []schema.Field{{Name: "field2", Kind: schema.StringKind}}}}) + if err != nil { + return schema.ModuleCodec{}, err + } return schema.ModuleCodec{ - Schema: schema.ModuleSchema{ObjectTypes: []schema.ObjectType{{Name: "B"}}}, + Schema: modSchema, }, nil } @@ -36,7 +44,13 @@ var testResolver = ModuleSetDecoderResolver(moduleSet) func TestModuleSetDecoderResolver_IterateAll(t *testing.T) { objectTypes := map[string]bool{} err := testResolver.IterateAll(func(moduleName string, cdc schema.ModuleCodec) error { - objectTypes[cdc.Schema.ObjectTypes[0].Name] = true + cdc.Schema.Types(func(t schema.Type) bool { + objTyp, ok := t.(schema.ObjectType) + if ok { + objectTypes[objTyp.Name] = true + } + return true + }) return nil }) if err != nil { @@ -66,8 +80,9 @@ func TestModuleSetDecoderResolver_LookupDecoder(t *testing.T) { t.Fatalf("expected to find decoder for modA") } - if decoder.Schema.ObjectTypes[0].Name != "A" { - t.Fatalf("expected object type A, got %s", decoder.Schema.ObjectTypes[0].Name) + _, ok := decoder.Schema.LookupType("A") + if !ok { + t.Fatalf("expected object type A") } decoder, found, err = testResolver.LookupDecoder("modB") @@ -79,8 +94,9 @@ func TestModuleSetDecoderResolver_LookupDecoder(t *testing.T) { t.Fatalf("expected to find decoder for modB") } - if decoder.Schema.ObjectTypes[0].Name != "B" { - t.Fatalf("expected object type B, got %s", decoder.Schema.ObjectTypes[0].Name) + _, ok = decoder.Schema.LookupType("B") + if !ok { + t.Fatalf("expected object type B") } decoder, found, err = testResolver.LookupDecoder("modC") diff --git a/schema/enum.go b/schema/enum.go index 927cc827cb3e..5afb0ecbd0b8 100644 --- a/schema/enum.go +++ b/schema/enum.go @@ -18,6 +18,8 @@ type EnumDefinition struct { Values []string } +func (EnumDefinition) isType() {} + // Validate validates the enum definition. func (e EnumDefinition) Validate() error { if !ValidateName(e.Name) { @@ -50,31 +52,3 @@ func (e EnumDefinition) ValidateValue(value string) error { } return fmt.Errorf("value %q is not a valid enum value for %s", value, e.Name) } - -// checkEnumCompatibility checks that the enum values are consistent across object types and fields. -func checkEnumCompatibility(enumValueMap map[string]map[string]bool, field Field) error { - if field.Kind != EnumKind { - return nil - } - - enum := field.EnumDefinition - - if existing, ok := enumValueMap[enum.Name]; ok { - if len(existing) != len(enum.Values) { - return fmt.Errorf("enum %q has different number of values in different object types", enum.Name) - } - - for _, value := range enum.Values { - if !existing[value] { - return fmt.Errorf("enum %q has different values in different object types", enum.Name) - } - } - } else { - valueMap := map[string]bool{} - for _, value := range enum.Values { - valueMap[value] = true - } - enumValueMap[enum.Name] = valueMap - } - return nil -} diff --git a/schema/module_schema.go b/schema/module_schema.go index 9412c4456cbe..b98744ea8142 100644 --- a/schema/module_schema.go +++ b/schema/module_schema.go @@ -1,18 +1,82 @@ package schema -import "fmt" +import ( + "fmt" + "sort" +) // ModuleSchema represents the logical schema of a module for purposes of indexing and querying. type ModuleSchema struct { - // ObjectTypes describe the types of objects that are part of the module's schema. - ObjectTypes []ObjectType + types map[string]Type +} + +// NewModuleSchema constructs a new ModuleSchema and validates it. Any module schema returned without an error +// is guaranteed to be valid. +func NewModuleSchema(objectTypes []ObjectType) (ModuleSchema, error) { + types := map[string]Type{} + + for _, objectType := range objectTypes { + types[objectType.Name] = objectType + } + + res := ModuleSchema{types: types} + + // validate adds all enum types to the type map + err := res.Validate() + if err != nil { + return ModuleSchema{}, err + } + + return res, nil +} + +func addEnumType(types map[string]Type, field Field) error { + enumDef := field.EnumDefinition + if enumDef.Name == "" { + return nil + } + + existing, ok := types[enumDef.Name] + if !ok { + types[enumDef.Name] = enumDef + return nil + } + + existingEnum, ok := existing.(EnumDefinition) + if !ok { + return fmt.Errorf("enum %q already exists as a different non-enum type", enumDef.Name) + } + + if len(existingEnum.Values) != len(enumDef.Values) { + return fmt.Errorf("enum %q has different number of values in different fields", enumDef.Name) + } + + existingValues := map[string]bool{} + for _, value := range existingEnum.Values { + existingValues[value] = true + } + + for _, value := range enumDef.Values { + _, ok := existingValues[value] + if !ok { + return fmt.Errorf("enum %q has different values in different fields", enumDef.Name) + } + } + + return nil } // Validate validates the module schema. func (s ModuleSchema) Validate() error { - enumValueMap := map[string]map[string]bool{} - for _, objType := range s.ObjectTypes { - if err := objType.validate(enumValueMap); err != nil { + for _, typ := range s.types { + objTyp, ok := typ.(ObjectType) + if !ok { + continue + } + + // all enum types get added to the type map when we call ObjectType.validate + err := objTyp.validate(s.types) + if err != nil { return err } } @@ -22,10 +86,36 @@ func (s ModuleSchema) Validate() error { // ValidateObjectUpdate validates that the update conforms to the module schema. func (s ModuleSchema) ValidateObjectUpdate(update ObjectUpdate) error { - for _, objType := range s.ObjectTypes { - if objType.Name == update.TypeName { - return objType.ValidateObjectUpdate(update) + typ, ok := s.types[update.TypeName] + if !ok { + return fmt.Errorf("object type %q not found in module schema", update.TypeName) + } + + objTyp, ok := typ.(ObjectType) + if !ok { + return fmt.Errorf("type %q is not an object type", update.TypeName) + } + + return objTyp.ValidateObjectUpdate(update) +} + +// LookupType looks up a type by name in the module schema. +func (s ModuleSchema) LookupType(name string) (Type, bool) { + typ, ok := s.types[name] + return typ, ok +} + +// Types calls the provided function for each type in the module schema and stops if the function returns false. +// The types are iterated over in sorted order by name. This function is compatible with go 1.23 iterators. +func (s ModuleSchema) Types(f func(Type) bool) { + keys := make([]string, 0, len(s.types)) + for k := range s.types { + keys = append(keys, k) + } + sort.Strings(keys) + for _, k := range keys { + if !f(s.types[k]) { + break } } - return fmt.Errorf("object type %q not found in module schema", update.TypeName) } diff --git a/schema/module_schema_test.go b/schema/module_schema_test.go index d04327811be6..189c7f3b9947 100644 --- a/schema/module_schema_test.go +++ b/schema/module_schema_test.go @@ -1,27 +1,26 @@ package schema import ( + "reflect" "strings" "testing" ) func TestModuleSchema_Validate(t *testing.T) { tests := []struct { - name string - moduleSchema ModuleSchema - errContains string + name string + objectTypes []ObjectType + errContains string }{ { name: "valid module schema", - moduleSchema: ModuleSchema{ - ObjectTypes: []ObjectType{ - { - Name: "object1", - KeyFields: []Field{ - { - Name: "field1", - Kind: StringKind, - }, + objectTypes: []ObjectType{ + { + Name: "object1", + KeyFields: []Field{ + { + Name: "field1", + Kind: StringKind, }, }, }, @@ -30,15 +29,13 @@ func TestModuleSchema_Validate(t *testing.T) { }, { name: "invalid object type", - moduleSchema: ModuleSchema{ - ObjectTypes: []ObjectType{ - { - Name: "", - KeyFields: []Field{ - { - Name: "field1", - Kind: StringKind, - }, + objectTypes: []ObjectType{ + { + Name: "", + KeyFields: []Field{ + { + Name: "field1", + Kind: StringKind, }, }, }, @@ -47,28 +44,26 @@ func TestModuleSchema_Validate(t *testing.T) { }, { name: "same enum with missing values", - moduleSchema: ModuleSchema{ - ObjectTypes: []ObjectType{ - { - Name: "object1", - KeyFields: []Field{ - { - Name: "k", - Kind: EnumKind, - EnumDefinition: EnumDefinition{ - Name: "enum1", - Values: []string{"a", "b"}, - }, + objectTypes: []ObjectType{ + { + Name: "object1", + KeyFields: []Field{ + { + Name: "k", + Kind: EnumKind, + EnumDefinition: EnumDefinition{ + Name: "enum1", + Values: []string{"a", "b"}, }, }, - ValueFields: []Field{ - { - Name: "v", - Kind: EnumKind, - EnumDefinition: EnumDefinition{ - Name: "enum1", - Values: []string{"a", "b", "c"}, - }, + }, + ValueFields: []Field{ + { + Name: "v", + Kind: EnumKind, + EnumDefinition: EnumDefinition{ + Name: "enum1", + Values: []string{"a", "b", "c"}, }, }, }, @@ -78,31 +73,29 @@ func TestModuleSchema_Validate(t *testing.T) { }, { name: "same enum with different values", - moduleSchema: ModuleSchema{ - ObjectTypes: []ObjectType{ - { - Name: "object1", - KeyFields: []Field{ - { - Name: "k", - Kind: EnumKind, - EnumDefinition: EnumDefinition{ - Name: "enum1", - Values: []string{"a", "b"}, - }, + objectTypes: []ObjectType{ + { + Name: "object1", + KeyFields: []Field{ + { + Name: "k", + Kind: EnumKind, + EnumDefinition: EnumDefinition{ + Name: "enum1", + Values: []string{"a", "b"}, }, }, }, - { - Name: "object2", - KeyFields: []Field{ - { - Name: "k", - Kind: EnumKind, - EnumDefinition: EnumDefinition{ - Name: "enum1", - Values: []string{"a", "c"}, - }, + }, + { + Name: "object2", + KeyFields: []Field{ + { + Name: "k", + Kind: EnumKind, + EnumDefinition: EnumDefinition{ + Name: "enum1", + Values: []string{"a", "c"}, }, }, }, @@ -112,42 +105,58 @@ func TestModuleSchema_Validate(t *testing.T) { }, { name: "same enum", - moduleSchema: ModuleSchema{ - ObjectTypes: []ObjectType{ + objectTypes: []ObjectType{{ + Name: "object1", + KeyFields: []Field{ { - Name: "object1", - KeyFields: []Field{ - { - Name: "k", - Kind: EnumKind, - EnumDefinition: EnumDefinition{ - Name: "enum1", - Values: []string{"a", "b"}, - }, + Name: "k", + Kind: EnumKind, + EnumDefinition: EnumDefinition{ + Name: "enum1", + Values: []string{"a", "b"}, + }, + }, + }, + }, + { + Name: "object2", + KeyFields: []Field{ + { + Name: "k", + Kind: EnumKind, + EnumDefinition: EnumDefinition{ + Name: "enum1", + Values: []string{"a", "b"}, }, }, }, - { - Name: "object2", - KeyFields: []Field{ - { - Name: "k", - Kind: EnumKind, - EnumDefinition: EnumDefinition{ - Name: "enum1", - Values: []string{"a", "b"}, - }, + }, + }, + }, + { + objectTypes: []ObjectType{ + { + Name: "type1", + ValueFields: []Field{ + { + Name: "field1", + Kind: EnumKind, + EnumDefinition: EnumDefinition{ + Name: "type1", + Values: []string{"a", "b"}, }, }, }, }, }, + errContains: "enum \"type1\" already exists as a different non-enum type", }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - err := tt.moduleSchema.Validate() + // because validate is called when calling NewModuleSchema, we just call NewModuleSchema + _, err := NewModuleSchema(tt.objectTypes) if tt.errContains == "" { if err != nil { t.Fatalf("unexpected error: %v", err) @@ -170,19 +179,18 @@ func TestModuleSchema_ValidateObjectUpdate(t *testing.T) { }{ { name: "valid object update", - moduleSchema: ModuleSchema{ - ObjectTypes: []ObjectType{ - { - Name: "object1", - KeyFields: []Field{ - { - Name: "field1", - Kind: StringKind, - }, + moduleSchema: RequireNewModuleSchema(t, []ObjectType{ + { + Name: "object1", + KeyFields: []Field{ + { + Name: "field1", + Kind: StringKind, }, }, }, }, + ), objectUpdate: ObjectUpdate{ TypeName: "object1", Key: "abc", @@ -191,25 +199,47 @@ func TestModuleSchema_ValidateObjectUpdate(t *testing.T) { }, { name: "object type not found", - moduleSchema: ModuleSchema{ - ObjectTypes: []ObjectType{ - { - Name: "object1", - KeyFields: []Field{ - { - Name: "field1", - Kind: StringKind, - }, + moduleSchema: RequireNewModuleSchema(t, []ObjectType{ + { + Name: "object1", + KeyFields: []Field{ + { + Name: "field1", + Kind: StringKind, }, }, }, }, + ), objectUpdate: ObjectUpdate{ TypeName: "object2", Key: "abc", }, errContains: "object type \"object2\" not found in module schema", }, + { + name: "type name refers to an enum", + moduleSchema: RequireNewModuleSchema(t, []ObjectType{ + { + Name: "obj1", + KeyFields: []Field{ + { + Name: "field1", + Kind: EnumKind, + EnumDefinition: EnumDefinition{ + Name: "enum1", + Values: []string{"a", "b"}, + }, + }, + }, + }, + }), + objectUpdate: ObjectUpdate{ + TypeName: "enum1", + Key: "a", + }, + errContains: "type \"enum1\" is not an object type", + }, } for _, tt := range tests { @@ -227,3 +257,94 @@ func TestModuleSchema_ValidateObjectUpdate(t *testing.T) { }) } } + +func RequireNewModuleSchema(t *testing.T, objectTypes []ObjectType) ModuleSchema { + t.Helper() + moduleSchema, err := NewModuleSchema(objectTypes) + if err != nil { + t.Fatalf("unexpected error: %v", err) + } + return moduleSchema +} + +func TestModuleSchema_LookupType(t *testing.T) { + moduleSchema := RequireNewModuleSchema(t, []ObjectType{ + { + Name: "object1", + KeyFields: []Field{ + { + Name: "field1", + Kind: StringKind, + }, + }, + }, + }) + + typ, ok := moduleSchema.LookupType("object1") + if !ok { + t.Fatalf("expected to find object type \"object1\"") + } + + objectType, ok := typ.(ObjectType) + if !ok { + t.Fatalf("expected object type, got %T", typ) + } + + if objectType.Name != "object1" { + t.Fatalf("expected object type name \"object1\", got %q", objectType.Name) + } +} + +func TestModuleSchema_ScanTypes(t *testing.T) { + moduleSchema := RequireNewModuleSchema(t, []ObjectType{ + { + Name: "object1", + KeyFields: []Field{ + { + Name: "field1", + Kind: StringKind, + }, + }, + }, + { + Name: "object2", + KeyFields: []Field{ + { + Name: "field1", + Kind: StringKind, + }, + }, + }, + }) + + var objectTypeNames []string + moduleSchema.Types(func(typ Type) bool { + objectType, ok := typ.(ObjectType) + if !ok { + t.Fatalf("expected object type, got %T", typ) + } + objectTypeNames = append(objectTypeNames, objectType.Name) + return true + }) + + expected := []string{"object1", "object2"} + if !reflect.DeepEqual(objectTypeNames, expected) { + t.Fatalf("expected object type names %v, got %v", expected, objectTypeNames) + } + + objectTypeNames = nil + // scan just the first type and return false + moduleSchema.Types(func(typ Type) bool { + objectType, ok := typ.(ObjectType) + if !ok { + t.Fatalf("expected object type, got %T", typ) + } + objectTypeNames = append(objectTypeNames, objectType.Name) + return false + }) + + expected = []string{"object1"} + if !reflect.DeepEqual(objectTypeNames, expected) { + t.Fatalf("expected object type names %v, got %v", expected, objectTypeNames) + } +} diff --git a/schema/object_type.go b/schema/object_type.go index a8fa432d8032..9dd3742a55d5 100644 --- a/schema/object_type.go +++ b/schema/object_type.go @@ -4,8 +4,8 @@ import "fmt" // ObjectType describes an object type a module schema. type ObjectType struct { - // Name is the name of the object type. It must be unique within the module schema - // and conform to the NameFormat regular expression. + // Name is the name of the object type. It must be unique within the module schema amongst all object and enum + // types and conform to the NameFormat regular expression. Name string // KeyFields is a list of fields that make up the primary key of the object. @@ -27,14 +27,16 @@ type ObjectType struct { RetainDeletions bool } +func (ObjectType) isType() {} + // Validate validates the object type. func (o ObjectType) Validate() error { - return o.validate(map[string]map[string]bool{}) + return o.validate(map[string]Type{}) } // validate validates the object type with an enumValueMap that can be // shared across a whole module schema. -func (o ObjectType) validate(enumValueMap map[string]map[string]bool) error { +func (o ObjectType) validate(types map[string]Type) error { if !ValidateName(o.Name) { return fmt.Errorf("invalid object type name %q", o.Name) } @@ -55,7 +57,8 @@ func (o ObjectType) validate(enumValueMap map[string]map[string]bool) error { } fieldNames[field.Name] = true - if err := checkEnumCompatibility(enumValueMap, field); err != nil { + err := addEnumType(types, field) + if err != nil { return err } } @@ -70,7 +73,8 @@ func (o ObjectType) validate(enumValueMap map[string]map[string]bool) error { } fieldNames[field.Name] = true - if err := checkEnumCompatibility(enumValueMap, field); err != nil { + err := addEnumType(types, field) + if err != nil { return err } } diff --git a/schema/type.go b/schema/type.go new file mode 100644 index 000000000000..1b3ef0657734 --- /dev/null +++ b/schema/type.go @@ -0,0 +1,7 @@ +package schema + +// Type is an interface that all types in the schema implement. +// Currently these are ObjectType and EnumDefinition. +type Type interface { + isType() +} From 4ea7f9fc82034079c4046a44be7fdfcb6503b81e Mon Sep 17 00:00:00 2001 From: Hieu Vu <72878483+hieuvubk@users.noreply.github.com> Date: Wed, 24 Jul 2024 14:12:52 +0700 Subject: [PATCH 34/50] docs(x/epochs): Fix proto comment (#21047) --- api/cosmos/epochs/module/v1/module.pulsar.go | 2 +- x/epochs/proto/cosmos/epochs/module/v1/module.proto | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/api/cosmos/epochs/module/v1/module.pulsar.go b/api/cosmos/epochs/module/v1/module.pulsar.go index b169d8466fc7..9adaff215156 100644 --- a/api/cosmos/epochs/module/v1/module.pulsar.go +++ b/api/cosmos/epochs/module/v1/module.pulsar.go @@ -382,7 +382,7 @@ const ( _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) ) -// Module is the config object of the authz module. +// Module is the config object of the epochs module. type Module struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache diff --git a/x/epochs/proto/cosmos/epochs/module/v1/module.proto b/x/epochs/proto/cosmos/epochs/module/v1/module.proto index 1b860b3e504b..786f99100c32 100644 --- a/x/epochs/proto/cosmos/epochs/module/v1/module.proto +++ b/x/epochs/proto/cosmos/epochs/module/v1/module.proto @@ -4,7 +4,7 @@ package cosmos.epochs.module.v1; import "cosmos/app/v1alpha1/module.proto"; -// Module is the config object of the authz module. +// Module is the config object of the epochs module. message Module { option (cosmos.app.v1alpha1.module) = { go_import: "cosmossdk.io/x/epochs" From 24977a92a26057c3b528890a84d7093dbb3c591b Mon Sep 17 00:00:00 2001 From: Marko Date: Wed, 24 Jul 2024 09:44:50 +0200 Subject: [PATCH 35/50] ci: add 52 labels and ci (#21041) --- .github/dependabot.yml | 20 ++++ .github/workflows/sims-052.yml | 145 ++++++++++++++++++++++++++++ .mergify.yml | 8 ++ client/v2/go.mod | 2 +- client/v2/internal/testpb/msg.proto | 4 +- server/v2/cometbft/go.mod | 2 +- simapp/go.mod | 2 +- simapp/v2/go.mod | 2 +- tests/go.mod | 2 +- x/accounts/defaults/lockup/go.mod | 2 +- x/accounts/defaults/multisig/go.mod | 2 +- x/accounts/go.mod | 2 +- x/auth/go.mod | 2 +- x/authz/go.mod | 2 +- x/bank/go.mod | 2 +- x/circuit/go.mod | 2 +- x/consensus/go.mod | 2 +- x/distribution/go.mod | 2 +- x/epochs/go.mod | 2 +- x/evidence/go.mod | 2 +- x/feegrant/go.mod | 2 +- x/gov/go.mod | 2 +- x/group/go.mod | 2 +- x/mint/go.mod | 2 +- x/nft/go.mod | 2 +- x/params/go.mod | 2 +- x/protocolpool/go.mod | 2 +- x/slashing/go.mod | 2 +- x/staking/go.mod | 2 +- x/upgrade/go.mod | 2 +- 30 files changed, 201 insertions(+), 28 deletions(-) create mode 100644 .github/workflows/sims-052.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 7af739bbcf30..98ae0c266d5c 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -356,3 +356,23 @@ updates: # cometbft 0.38 is not semver, but we want to only update "patch" versions for 0.38.x update-types: ["version-update:semver-major", "version-update:semver-minor"] + + - package-ecosystem: gomod + directory: "/" + target-branch: "release/v0.52.x" + schedule: + interval: daily + time: "03:00" + labels: + - "A:automerge" + - dependencies + - "testing-required" + allow: + - dependency-name: "github.com/cosmos/cosmos-sdk/*" + dependency-type: "all" + - dependency-name: "github.com/cosmos/*" + dependency-type: "all" + - dependency-name: "cosmossdk.io/*" + dependency-type: "all" + - dependency-name: "github.com/cometbft/*" + dependency-type: "all" diff --git a/.github/workflows/sims-052.yml b/.github/workflows/sims-052.yml new file mode 100644 index 000000000000..e79a04786098 --- /dev/null +++ b/.github/workflows/sims-052.yml @@ -0,0 +1,145 @@ +name: Sims release/0.52.x +# Sims workflow runs multiple types of simulations (nondeterminism, import-export, after-import, multi-seed-short) +# This workflow will run on all Pull Requests, if a .go, .mod or .sum file have been changed +on: + schedule: + - cron: "0 0,12 * * *" + release: + types: [published] + +concurrency: + group: ci-${{ github.ref }}-sims-052 + cancel-in-progress: true + +jobs: + build: + runs-on: ubuntu-latest + if: "!contains(github.event.head_commit.message, 'skip-sims')" + steps: + - uses: actions/checkout@v4 + with: + ref: "release/v0.52.x" + - uses: actions/setup-go@v5 + with: + go-version: "1.22" + check-latest: true + - run: make build + + install-runsim: + permissions: + contents: none + runs-on: ubuntu-latest + needs: build + steps: + - uses: actions/setup-go@v5 + with: + go-version: "1.22" + check-latest: true + - name: Install runsim + run: go install github.com/cosmos/tools/cmd/runsim@v1.0.0 + - uses: actions/cache@v4 + with: + path: ~/go/bin + key: ${{ runner.os }}-go-runsim-binary + + test-sim-import-export: + runs-on: ubuntu-latest + needs: [build, install-runsim] + timeout-minutes: 60 + steps: + - uses: actions/checkout@v4 + with: + ref: "release/v0.52.x" + - uses: actions/setup-go@v5 + with: + go-version: "1.22" + check-latest: true + - uses: actions/cache@v4 + with: + path: ~/go/bin + key: ${{ runner.os }}-go-runsim-binary + - name: test-sim-import-export + run: | + make test-sim-import-export + + test-sim-after-import: + runs-on: ubuntu-latest + needs: [build, install-runsim] + steps: + - uses: actions/checkout@v4 + with: + ref: "release/v0.52.x" + - uses: actions/setup-go@v5 + with: + go-version: "1.22" + check-latest: true + - uses: actions/cache@v4 + with: + path: ~/go/bin + key: ${{ runner.os }}-go-runsim-binary + - name: test-sim-after-import + run: | + make test-sim-after-import + + test-sim-multi-seed-short: + runs-on: ubuntu-latest + needs: [build, install-runsim] + steps: + - uses: actions/checkout@v4 + with: + ref: "release/v0.52.x" + - uses: actions/setup-go@v5 + with: + go-version: "1.22" + check-latest: true + - uses: actions/cache@v4 + with: + path: ~/go/bin + key: ${{ runner.os }}-go-runsim-binary + - name: test-sim-multi-seed-short + run: | + make test-sim-multi-seed-short + + sims-notify-success: + needs: + [test-sim-multi-seed-short, test-sim-after-import, test-sim-import-export] + runs-on: ubuntu-latest + if: ${{ success() }} + steps: + - uses: actions/checkout@v4 + - name: Get previous workflow status + uses: ./.github/actions/last-workflow-status + id: last_status + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + + - name: Notify Slack on success + if: ${{ steps.last_status.outputs.last_status == 'failure' }} + uses: rtCamp/action-slack-notify@v2.3.0 + env: + SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }} + SLACK_CHANNEL: sdk-sims + SLACK_USERNAME: Sim Tests release/0.52.x + SLACK_ICON_EMOJI: ":white_check_mark:" + SLACK_COLOR: good + SLACK_MESSAGE: 0.52.x Sims are passing + SLACK_FOOTER: "" + + sims-notify-failure: + permissions: + contents: none + needs: + [test-sim-multi-seed-short, test-sim-after-import, test-sim-import-export] + runs-on: ubuntu-latest + if: ${{ failure() }} + steps: + - name: Notify Slack on failure + uses: rtCamp/action-slack-notify@v2.3.0 + env: + SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }} + SLACK_CHANNEL: sdk-sims + SLACK_USERNAME: Sim Tests release/0.52.x + SLACK_ICON_EMOJI: ":skull:" + SLACK_COLOR: danger + SLACK_MESSAGE: 0.52.x Sims are failing + SLACK_FOOTER: "" diff --git a/.mergify.yml b/.mergify.yml index 23eb45476a4b..810131c70c95 100644 --- a/.mergify.yml +++ b/.mergify.yml @@ -16,6 +16,14 @@ pull_request_rules: commit_message_template: | {{ title }} (#{{ number }}) {{ body }} + - name: backport patches to v0.52.x branch + conditions: + - base=main + - label=backport/v0.52.x + actions: + backport: + branches: + - release/v0.52.x - name: backport patches to v0.50.x branch conditions: - base=main diff --git a/client/v2/go.mod b/client/v2/go.mod index d6e3d4e93680..7cf66843c08f 100644 --- a/client/v2/go.mod +++ b/client/v2/go.mod @@ -10,7 +10,7 @@ require ( cosmossdk.io/x/gov v0.0.0-20231113122742-912390d5fc4a cosmossdk.io/x/tx v0.13.3 github.com/cosmos/cosmos-proto v1.0.0-beta.5 - github.com/cosmos/cosmos-sdk v0.51.0 + github.com/cosmos/cosmos-sdk v0.53.0 github.com/spf13/cobra v1.8.1 github.com/spf13/pflag v1.0.5 google.golang.org/grpc v1.64.1 diff --git a/client/v2/internal/testpb/msg.proto b/client/v2/internal/testpb/msg.proto index a1360175d0a1..52096ebd58e7 100644 --- a/client/v2/internal/testpb/msg.proto +++ b/client/v2/internal/testpb/msg.proto @@ -16,7 +16,7 @@ service Msg { }; rpc Clawback(MsgClawbackRequest) returns (MsgClawbackResponse) { - option (cosmos_proto.method_added_in) = "cosmos-sdk v0.51.0"; + option (cosmos_proto.method_added_in) = "cosmos-sdk v0.53.0 "; } } @@ -59,4 +59,4 @@ message MsgResponse { message MsgClawbackRequest {} -message MsgClawbackResponse {} \ No newline at end of file +message MsgClawbackResponse {} diff --git a/server/v2/cometbft/go.mod b/server/v2/cometbft/go.mod index b33ca719aef4..c10a4dc2725b 100644 --- a/server/v2/cometbft/go.mod +++ b/server/v2/cometbft/go.mod @@ -32,7 +32,7 @@ require ( github.com/cometbft/cometbft v1.0.0-rc1 github.com/cometbft/cometbft/api v1.0.0-rc.1 github.com/cosmos/cosmos-proto v1.0.0-beta.5 - github.com/cosmos/cosmos-sdk v0.51.0 + github.com/cosmos/cosmos-sdk v0.53.0 github.com/cosmos/gogoproto v1.5.0 github.com/golang/protobuf v1.5.4 github.com/grpc-ecosystem/grpc-gateway v1.16.0 diff --git a/simapp/go.mod b/simapp/go.mod index 5d67518fce5a..b6eb81a294d8 100644 --- a/simapp/go.mod +++ b/simapp/go.mod @@ -37,7 +37,7 @@ require ( github.com/cometbft/cometbft/api v1.0.0-rc.1 github.com/cosmos/cosmos-db v1.0.2 // this version is not used as it is always replaced by the latest Cosmos SDK version - github.com/cosmos/cosmos-sdk v0.51.0 + github.com/cosmos/cosmos-sdk v0.53.0 github.com/cosmos/gogoproto v1.5.0 github.com/golang/mock v1.6.0 github.com/spf13/cast v1.6.0 diff --git a/simapp/v2/go.mod b/simapp/v2/go.mod index 4953ca17b529..8b595badf809 100644 --- a/simapp/v2/go.mod +++ b/simapp/v2/go.mod @@ -34,7 +34,7 @@ require ( github.com/cometbft/cometbft v1.0.0-rc1 github.com/cosmos/cosmos-db v1.0.2 // this version is not used as it is always replaced by the latest Cosmos SDK version - github.com/cosmos/cosmos-sdk v0.51.0 + github.com/cosmos/cosmos-sdk v0.53.0 github.com/spf13/cobra v1.8.1 github.com/spf13/pflag v1.0.5 github.com/spf13/viper v1.19.0 diff --git a/tests/go.mod b/tests/go.mod index e0ad26aa6b25..ce552b6aa693 100644 --- a/tests/go.mod +++ b/tests/go.mod @@ -22,7 +22,7 @@ require ( github.com/cosmos/cosmos-db v1.0.2 github.com/cosmos/cosmos-proto v1.0.0-beta.5 // this version is not used as it is always replaced by the latest Cosmos SDK version - github.com/cosmos/cosmos-sdk v0.51.0 + github.com/cosmos/cosmos-sdk v0.53.0 github.com/cosmos/gogoproto v1.5.0 github.com/golang/mock v1.6.0 github.com/spf13/cobra v1.8.1 diff --git a/x/accounts/defaults/lockup/go.mod b/x/accounts/defaults/lockup/go.mod index daa4b58f5325..3b29b91f3acd 100644 --- a/x/accounts/defaults/lockup/go.mod +++ b/x/accounts/defaults/lockup/go.mod @@ -9,7 +9,7 @@ require ( cosmossdk.io/x/bank v0.0.0-20240226161501-23359a0b6d91 cosmossdk.io/x/distribution v0.0.0-00010101000000-000000000000 cosmossdk.io/x/staking v0.0.0-00010101000000-000000000000 - github.com/cosmos/cosmos-sdk v0.51.0 + github.com/cosmos/cosmos-sdk v0.53.0 github.com/cosmos/gogoproto v1.5.0 ) diff --git a/x/accounts/defaults/multisig/go.mod b/x/accounts/defaults/multisig/go.mod index 4a7254390618..4d2f36bbf0b0 100644 --- a/x/accounts/defaults/multisig/go.mod +++ b/x/accounts/defaults/multisig/go.mod @@ -9,7 +9,7 @@ require ( cosmossdk.io/x/accounts v0.0.0-00010101000000-000000000000 cosmossdk.io/x/bank v0.0.0-20240226161501-23359a0b6d91 github.com/cosmos/cosmos-proto v1.0.0-beta.5 - github.com/cosmos/cosmos-sdk v0.51.0 + github.com/cosmos/cosmos-sdk v0.53.0 github.com/cosmos/gogoproto v1.5.0 github.com/stretchr/testify v1.9.0 google.golang.org/protobuf v1.34.2 diff --git a/x/accounts/go.mod b/x/accounts/go.mod index 30ddbf7df8f7..6a31a443a567 100644 --- a/x/accounts/go.mod +++ b/x/accounts/go.mod @@ -11,7 +11,7 @@ require ( cosmossdk.io/x/accounts/defaults/multisig v0.0.0-00010101000000-000000000000 cosmossdk.io/x/bank v0.0.0-20240226161501-23359a0b6d91 cosmossdk.io/x/tx v0.13.3 - github.com/cosmos/cosmos-sdk v0.51.0 + github.com/cosmos/cosmos-sdk v0.53.0 github.com/cosmos/gogoproto v1.5.0 github.com/decred/dcrd/dcrec/secp256k1/v4 v4.3.0 github.com/spf13/cobra v1.8.1 diff --git a/x/auth/go.mod b/x/auth/go.mod index a22cb0b4b0d7..fc2484be29d2 100644 --- a/x/auth/go.mod +++ b/x/auth/go.mod @@ -16,7 +16,7 @@ require ( github.com/cometbft/cometbft v1.0.0-rc1 github.com/cometbft/cometbft/api v1.0.0-rc.1 github.com/cosmos/cosmos-proto v1.0.0-beta.5 - github.com/cosmos/cosmos-sdk v0.51.0 + github.com/cosmos/cosmos-sdk v0.53.0 github.com/cosmos/gogoproto v1.5.0 github.com/decred/dcrd/dcrec/secp256k1/v4 v4.3.0 github.com/golang/mock v1.6.0 diff --git a/x/authz/go.mod b/x/authz/go.mod index a262c055d6fc..0d3fa3c1bce2 100644 --- a/x/authz/go.mod +++ b/x/authz/go.mod @@ -15,7 +15,7 @@ require ( github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06 // indirect github.com/cometbft/cometbft v1.0.0-rc1 github.com/cosmos/cosmos-proto v1.0.0-beta.5 - github.com/cosmos/cosmos-sdk v0.51.0 + github.com/cosmos/cosmos-sdk v0.53.0 github.com/cosmos/gogoproto v1.5.0 github.com/golang/mock v1.6.0 github.com/golang/protobuf v1.5.4 diff --git a/x/bank/go.mod b/x/bank/go.mod index 480d7c39ba4e..4346329fe3a4 100644 --- a/x/bank/go.mod +++ b/x/bank/go.mod @@ -14,7 +14,7 @@ require ( github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06 // indirect github.com/cometbft/cometbft v1.0.0-rc1 github.com/cosmos/cosmos-proto v1.0.0-beta.5 - github.com/cosmos/cosmos-sdk v0.51.0 + github.com/cosmos/cosmos-sdk v0.53.0 github.com/cosmos/gogoproto v1.5.0 github.com/golang/mock v1.6.0 github.com/golang/protobuf v1.5.4 diff --git a/x/circuit/go.mod b/x/circuit/go.mod index 68b9e5ca1ff6..654470697deb 100644 --- a/x/circuit/go.mod +++ b/x/circuit/go.mod @@ -11,7 +11,7 @@ require ( cosmossdk.io/errors v1.0.1 cosmossdk.io/store v1.1.1-0.20240418092142-896cdf1971bc cosmossdk.io/x/auth v0.0.0-00010101000000-000000000000 - github.com/cosmos/cosmos-sdk v0.51.0 + github.com/cosmos/cosmos-sdk v0.53.0 github.com/cosmos/gogoproto v1.5.0 github.com/golang/protobuf v1.5.4 github.com/grpc-ecosystem/grpc-gateway v1.16.0 diff --git a/x/consensus/go.mod b/x/consensus/go.mod index 3ca3a4af640b..1577c4a61aa6 100644 --- a/x/consensus/go.mod +++ b/x/consensus/go.mod @@ -12,7 +12,7 @@ require ( github.com/cometbft/cometbft v1.0.0-rc1 github.com/cometbft/cometbft/api v1.0.0-rc.1 github.com/cosmos/cosmos-proto v1.0.0-beta.5 - github.com/cosmos/cosmos-sdk v0.51.0 + github.com/cosmos/cosmos-sdk v0.53.0 github.com/cosmos/gogoproto v1.5.0 github.com/golang/protobuf v1.5.4 github.com/grpc-ecosystem/grpc-gateway v1.16.0 diff --git a/x/distribution/go.mod b/x/distribution/go.mod index 5773e7fb3c21..a429835f472d 100644 --- a/x/distribution/go.mod +++ b/x/distribution/go.mod @@ -16,7 +16,7 @@ require ( cosmossdk.io/x/protocolpool v0.0.0-20230925135524-a1bc045b3190 cosmossdk.io/x/staking v0.0.0-00010101000000-000000000000 github.com/cosmos/cosmos-proto v1.0.0-beta.5 - github.com/cosmos/cosmos-sdk v0.51.0 + github.com/cosmos/cosmos-sdk v0.53.0 github.com/cosmos/gogoproto v1.5.0 github.com/golang/mock v1.6.0 github.com/golang/protobuf v1.5.4 diff --git a/x/epochs/go.mod b/x/epochs/go.mod index 4642488a952e..ac8c5c24e823 100644 --- a/x/epochs/go.mod +++ b/x/epochs/go.mod @@ -11,7 +11,7 @@ require ( cosmossdk.io/errors v1.0.1 cosmossdk.io/store v1.1.1-0.20240418092142-896cdf1971bc github.com/cosmos/cosmos-proto v1.0.0-beta.5 - github.com/cosmos/cosmos-sdk v0.51.0 + github.com/cosmos/cosmos-sdk v0.53.0 github.com/cosmos/gogoproto v1.5.0 github.com/golang/protobuf v1.5.4 github.com/grpc-ecosystem/grpc-gateway v1.16.0 diff --git a/x/evidence/go.mod b/x/evidence/go.mod index 680c72d2d6ce..48d3b802e6a9 100644 --- a/x/evidence/go.mod +++ b/x/evidence/go.mod @@ -13,7 +13,7 @@ require ( cosmossdk.io/store v1.1.1-0.20240418092142-896cdf1971bc cosmossdk.io/x/consensus v0.0.0-00010101000000-000000000000 github.com/cosmos/cosmos-proto v1.0.0-beta.5 - github.com/cosmos/cosmos-sdk v0.51.0 + github.com/cosmos/cosmos-sdk v0.53.0 github.com/cosmos/gogoproto v1.5.0 github.com/golang/mock v1.6.0 github.com/golang/protobuf v1.5.4 diff --git a/x/feegrant/go.mod b/x/feegrant/go.mod index 87acb3ccf648..635aae076608 100644 --- a/x/feegrant/go.mod +++ b/x/feegrant/go.mod @@ -15,7 +15,7 @@ require ( cosmossdk.io/x/gov v0.0.0-20230925135524-a1bc045b3190 github.com/cometbft/cometbft v1.0.0-rc1 github.com/cosmos/cosmos-proto v1.0.0-beta.5 - github.com/cosmos/cosmos-sdk v0.51.0 + github.com/cosmos/cosmos-sdk v0.53.0 github.com/cosmos/gogoproto v1.5.0 github.com/golang/mock v1.6.0 github.com/golang/protobuf v1.5.4 diff --git a/x/gov/go.mod b/x/gov/go.mod index c15954f2056a..df9c1d63dd96 100644 --- a/x/gov/go.mod +++ b/x/gov/go.mod @@ -19,7 +19,7 @@ require ( github.com/chzyer/readline v1.5.1 github.com/cometbft/cometbft v1.0.0-rc1 github.com/cosmos/cosmos-proto v1.0.0-beta.5 - github.com/cosmos/cosmos-sdk v0.51.0 + github.com/cosmos/cosmos-sdk v0.53.0 github.com/cosmos/gogoproto v1.5.0 github.com/golang/mock v1.6.0 github.com/golang/protobuf v1.5.4 diff --git a/x/group/go.mod b/x/group/go.mod index e0b54245f1d7..6ee302bcfafc 100644 --- a/x/group/go.mod +++ b/x/group/go.mod @@ -23,7 +23,7 @@ require ( github.com/cometbft/cometbft/api v1.0.0-rc.1 github.com/cosmos/cosmos-db v1.0.2 github.com/cosmos/cosmos-proto v1.0.0-beta.5 - github.com/cosmos/cosmos-sdk v0.51.0 + github.com/cosmos/cosmos-sdk v0.53.0 github.com/cosmos/gogoproto v1.5.0 github.com/golang/mock v1.6.0 github.com/golang/protobuf v1.5.4 diff --git a/x/mint/go.mod b/x/mint/go.mod index 6305bbf9f42c..bbbc298e8dca 100644 --- a/x/mint/go.mod +++ b/x/mint/go.mod @@ -14,7 +14,7 @@ require ( cosmossdk.io/x/epochs v0.0.0-20240522060652-a1ae4c3e0337 github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06 // indirect github.com/cosmos/cosmos-proto v1.0.0-beta.5 - github.com/cosmos/cosmos-sdk v0.51.0 + github.com/cosmos/cosmos-sdk v0.53.0 github.com/cosmos/gogoproto v1.5.0 github.com/golang/mock v1.6.0 github.com/golang/protobuf v1.5.4 diff --git a/x/nft/go.mod b/x/nft/go.mod index 28d524d6d9f5..fc10149a2abd 100644 --- a/x/nft/go.mod +++ b/x/nft/go.mod @@ -11,7 +11,7 @@ require ( cosmossdk.io/math v1.3.0 cosmossdk.io/store v1.1.1-0.20240418092142-896cdf1971bc github.com/cosmos/cosmos-proto v1.0.0-beta.5 - github.com/cosmos/cosmos-sdk v0.51.0 + github.com/cosmos/cosmos-sdk v0.53.0 github.com/cosmos/gogoproto v1.5.0 github.com/golang/mock v1.6.0 github.com/golang/protobuf v1.5.4 diff --git a/x/params/go.mod b/x/params/go.mod index ca7924a8fe9f..89d78a5e5826 100644 --- a/x/params/go.mod +++ b/x/params/go.mod @@ -14,7 +14,7 @@ require ( github.com/cometbft/cometbft/api v1.0.0-rc.1 github.com/cosmos/cosmos-db v1.0.2 github.com/cosmos/cosmos-proto v1.0.0-beta.5 - github.com/cosmos/cosmos-sdk v0.51.0 + github.com/cosmos/cosmos-sdk v0.53.0 github.com/cosmos/gogoproto v1.5.0 github.com/golang/mock v1.6.0 github.com/golang/protobuf v1.5.4 diff --git a/x/protocolpool/go.mod b/x/protocolpool/go.mod index c0959364d6ad..0c4ad683e2a7 100644 --- a/x/protocolpool/go.mod +++ b/x/protocolpool/go.mod @@ -13,7 +13,7 @@ require ( cosmossdk.io/store v1.1.1-0.20240418092142-896cdf1971bc cosmossdk.io/x/auth v0.0.0-00010101000000-000000000000 github.com/cosmos/cosmos-proto v1.0.0-beta.5 - github.com/cosmos/cosmos-sdk v0.51.0 + github.com/cosmos/cosmos-sdk v0.53.0 github.com/cosmos/gogoproto v1.5.0 github.com/golang/mock v1.6.0 github.com/golang/protobuf v1.5.4 diff --git a/x/slashing/go.mod b/x/slashing/go.mod index b60bdb431e11..90077e025001 100644 --- a/x/slashing/go.mod +++ b/x/slashing/go.mod @@ -15,7 +15,7 @@ require ( cosmossdk.io/x/staking v0.0.0-00010101000000-000000000000 github.com/bits-and-blooms/bitset v1.10.0 github.com/cosmos/cosmos-proto v1.0.0-beta.5 - github.com/cosmos/cosmos-sdk v0.51.0 + github.com/cosmos/cosmos-sdk v0.53.0 github.com/cosmos/gogoproto v1.5.0 github.com/golang/mock v1.6.0 github.com/golang/protobuf v1.5.4 diff --git a/x/staking/go.mod b/x/staking/go.mod index 5ad5d4f275cf..8f761dfc98cd 100644 --- a/x/staking/go.mod +++ b/x/staking/go.mod @@ -14,7 +14,7 @@ require ( github.com/cometbft/cometbft v1.0.0-rc1 github.com/cometbft/cometbft/api v1.0.0-rc.1 github.com/cosmos/cosmos-proto v1.0.0-beta.5 - github.com/cosmos/cosmos-sdk v0.51.0 + github.com/cosmos/cosmos-sdk v0.53.0 github.com/cosmos/gogoproto v1.5.0 github.com/golang/mock v1.6.0 github.com/golang/protobuf v1.5.4 diff --git a/x/upgrade/go.mod b/x/upgrade/go.mod index e646726b215b..ad960559819b 100644 --- a/x/upgrade/go.mod +++ b/x/upgrade/go.mod @@ -17,7 +17,7 @@ require ( github.com/cometbft/cometbft/api v1.0.0-rc.1 github.com/cosmos/cosmos-db v1.0.2 github.com/cosmos/cosmos-proto v1.0.0-beta.5 - github.com/cosmos/cosmos-sdk v0.51.0 + github.com/cosmos/cosmos-sdk v0.53.0 github.com/cosmos/gogoproto v1.5.0 github.com/golang/protobuf v1.5.4 github.com/grpc-ecosystem/grpc-gateway v1.16.0 From 18dd65d714132781d00fbff7dda023e2e6c9576f Mon Sep 17 00:00:00 2001 From: Alexander Peters Date: Wed, 24 Jul 2024 10:54:17 +0200 Subject: [PATCH 36/50] test(sims): Reduce test scope to 150 blocks for long sim run (#21049) --- scripts/build/simulations.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/build/simulations.mk b/scripts/build/simulations.mk index 6d0f077e6d87..ea7510db4cb8 100644 --- a/scripts/build/simulations.mk +++ b/scripts/build/simulations.mk @@ -45,7 +45,7 @@ test-sim-custom-genesis-multi-seed: test-sim-multi-seed-long: @echo "Running long multi-seed application simulation. This may take awhile!" @cd ${CURRENT_DIR}/simapp && go test -mod=readonly -timeout=1h -tags='sims' -run TestFullAppSimulation \ - -NumBlocks=500 -Period=50 + -NumBlocks=150 -Period=50 test-sim-multi-seed-short: @echo "Running short multi-seed application simulation. This may take awhile!" From e00145735ab45cf3f60a388575425a90fa6107f3 Mon Sep 17 00:00:00 2001 From: Hieu Vu <72878483+hieuvubk@users.noreply.github.com> Date: Wed, 24 Jul 2024 16:22:06 +0700 Subject: [PATCH 37/50] refactor(server/v2/cometbft): typecast SC & SS to correct interfaces (#21050) --- server/v2/cometbft/server.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/server/v2/cometbft/server.go b/server/v2/cometbft/server.go index 1553a5c9a592..88b5aa50a4ea 100644 --- a/server/v2/cometbft/server.go +++ b/server/v2/cometbft/server.go @@ -72,6 +72,7 @@ func (s *CometBFTServer[T]) Init(appI serverv2.AppI[T], v *viper.Viper, logger l } s.logger = logger.With(log.ModuleKey, s.Name()) + store := appI.GetStore().(types.Store) consensus := NewConsensus( s.logger, appI.Name(), @@ -80,7 +81,7 @@ func (s *CometBFTServer[T]) Init(appI serverv2.AppI[T], v *viper.Viper, logger l s.serverOptions.Mempool, indexEvents, appI.GetGRPCQueryDecoders(), - appI.GetStore().(types.Store), + store, s.config, s.initTxCodec, ) @@ -91,9 +92,8 @@ func (s *CometBFTServer[T]) Init(appI serverv2.AppI[T], v *viper.Viper, logger l consensus.addrPeerFilter = s.serverOptions.AddrPeerFilter consensus.idPeerFilter = s.serverOptions.IdPeerFilter - // TODO: set these; what is the appropriate presence of the Store interface here? - var ss snapshots.StorageSnapshotter - var sc snapshots.CommitSnapshotter + ss := store.GetStateStorage().(snapshots.StorageSnapshotter) + sc := store.GetStateCommitment().(snapshots.CommitSnapshotter) snapshotStore, err := GetSnapshotStore(s.config.ConfigTomlConfig.RootDir) if err != nil { From e8222c8092dedd4340e9599b38be414fac2293d8 Mon Sep 17 00:00:00 2001 From: Facundo Medica <14063057+facundomedica@users.noreply.github.com> Date: Wed, 24 Jul 2024 13:06:41 +0200 Subject: [PATCH 38/50] fix(x/slashing): do not error when val has zero tokens (#20977) --- .../keeper/slash_redelegation_test.go | 135 ++++++++++++++++++ x/staking/keeper/slash.go | 7 +- 2 files changed, 138 insertions(+), 4 deletions(-) diff --git a/tests/integration/slashing/keeper/slash_redelegation_test.go b/tests/integration/slashing/keeper/slash_redelegation_test.go index ad6dd9abd57a..96f6a50db081 100644 --- a/tests/integration/slashing/keeper/slash_redelegation_test.go +++ b/tests/integration/slashing/keeper/slash_redelegation_test.go @@ -365,3 +365,138 @@ func TestOverSlashing(t *testing.T) { require.Equal(t, "550000stake", balance2AfterSlashing.String()) require.Equal(t, "550000stake", balance3AfterSlashing.String()) } + +func TestSlashRedelegation_ValidatorLeftWithNoTokens(t *testing.T) { + // setting up + var ( + authKeeper authkeeper.AccountKeeper + stakingKeeper *stakingkeeper.Keeper + bankKeeper bankkeeper.Keeper + slashKeeper slashingkeeper.Keeper + distrKeeper distributionkeeper.Keeper + ) + + app, err := simtestutil.Setup( + depinject.Configs( + depinject.Supply(log.NewNopLogger()), + slashing.AppConfig, + ), + &stakingKeeper, + &bankKeeper, + &slashKeeper, + &distrKeeper, + &authKeeper, + ) + require.NoError(t, err) + + // get sdk context, staking msg server and bond denom + ctx := app.BaseApp.NewContext(false).WithBlockHeight(1).WithHeaderInfo(header.Info{Height: 1}) + stakingMsgServer := stakingkeeper.NewMsgServerImpl(stakingKeeper) + bondDenom, err := stakingKeeper.BondDenom(ctx) + require.NoError(t, err) + + // create validators DST and SRC + dstPubKey := secp256k1.GenPrivKey().PubKey() + srcPubKey := secp256k1.GenPrivKey().PubKey() + + dstAddr := sdk.ValAddress(dstPubKey.Address()) + srcAddr := sdk.ValAddress(srcPubKey.Address()) + + testCoin := sdk.NewCoin(bondDenom, stakingKeeper.TokensFromConsensusPower(ctx, 1000)) + fundAccount(t, ctx, bankKeeper, authKeeper, sdk.AccAddress(dstAddr), testCoin) + fundAccount(t, ctx, bankKeeper, authKeeper, sdk.AccAddress(srcAddr), testCoin) + + createValMsgDST, _ := stakingtypes.NewMsgCreateValidator( + dstAddr.String(), dstPubKey, testCoin, stakingtypes.Description{Details: "Validator DST"}, stakingtypes.NewCommissionRates(math.LegacyNewDecWithPrec(5, 1), math.LegacyNewDecWithPrec(5, 1), math.LegacyNewDec(0)), math.OneInt()) + _, err = stakingMsgServer.CreateValidator(ctx, createValMsgDST) + require.NoError(t, err) + + createValMsgSRC, _ := stakingtypes.NewMsgCreateValidator( + srcAddr.String(), srcPubKey, testCoin, stakingtypes.Description{Details: "Validator SRC"}, stakingtypes.NewCommissionRates(math.LegacyNewDecWithPrec(5, 1), math.LegacyNewDecWithPrec(5, 1), math.LegacyNewDec(0)), math.OneInt()) + _, err = stakingMsgServer.CreateValidator(ctx, createValMsgSRC) + require.NoError(t, err) + + // create a user accounts and delegate to SRC and DST + userAcc := sdk.AccAddress([]byte("user1_______________")) + fundAccount(t, ctx, bankKeeper, authKeeper, userAcc, testCoin) + + userAcc2 := sdk.AccAddress([]byte("user2_______________")) + fundAccount(t, ctx, bankKeeper, authKeeper, userAcc2, testCoin) + + delMsg := stakingtypes.NewMsgDelegate(userAcc.String(), srcAddr.String(), testCoin) + _, err = stakingMsgServer.Delegate(ctx, delMsg) + require.NoError(t, err) + + delMsg = stakingtypes.NewMsgDelegate(userAcc2.String(), dstAddr.String(), testCoin) + _, err = stakingMsgServer.Delegate(ctx, delMsg) + require.NoError(t, err) + + ctx, err = simtestutil.NextBlock(app, ctx, time.Duration(1)) + require.NoError(t, err) + + // commit an infraction with DST and store the power at this height + dstVal, err := stakingKeeper.GetValidator(ctx, dstAddr) + require.NoError(t, err) + dstPower := stakingKeeper.TokensToConsensusPower(ctx, dstVal.Tokens) + dstConsAddr, err := dstVal.GetConsAddr() + require.NoError(t, err) + dstInfractionHeight := ctx.BlockHeight() + + ctx, err = simtestutil.NextBlock(app, ctx, time.Duration(1)) + require.NoError(t, err) + + // undelegate all the user tokens from DST + undelMsg := stakingtypes.NewMsgUndelegate(userAcc2.String(), dstAddr.String(), testCoin) + _, err = stakingMsgServer.Undelegate(ctx, undelMsg) + require.NoError(t, err) + + // commit an infraction with SRC and store the power at this height + srcVal, err := stakingKeeper.GetValidator(ctx, srcAddr) + require.NoError(t, err) + srcPower := stakingKeeper.TokensToConsensusPower(ctx, srcVal.Tokens) + srcConsAddr, err := srcVal.GetConsAddr() + require.NoError(t, err) + srcInfractionHeight := ctx.BlockHeight() + + ctx, err = simtestutil.NextBlock(app, ctx, time.Duration(1)) + require.NoError(t, err) + + // redelegate all the user tokens from SRC to DST + redelMsg := stakingtypes.NewMsgBeginRedelegate(userAcc.String(), srcAddr.String(), dstAddr.String(), testCoin) + _, err = stakingMsgServer.BeginRedelegate(ctx, redelMsg) + require.NoError(t, err) + + // undelegate the self delegation from DST + undelMsg = stakingtypes.NewMsgUndelegate(sdk.AccAddress(dstAddr).String(), dstAddr.String(), testCoin) + _, err = stakingMsgServer.Undelegate(ctx, undelMsg) + require.NoError(t, err) + + ctx, err = simtestutil.NextBlock(app, ctx, time.Duration(1)) + require.NoError(t, err) + + undelMsg = stakingtypes.NewMsgUndelegate(userAcc.String(), dstAddr.String(), testCoin) + _, err = stakingMsgServer.Undelegate(ctx, undelMsg) + require.NoError(t, err) + + // check that dst now has zero tokens + valDst, err := stakingKeeper.GetValidator(ctx, dstAddr) + require.NoError(t, err) + require.Equal(t, math.ZeroInt().String(), valDst.Tokens.String()) + + // slash the infractions + err = slashKeeper.Slash(ctx, dstConsAddr, math.LegacyMustNewDecFromStr("0.8"), dstPower, dstInfractionHeight) + require.NoError(t, err) + + err = slashKeeper.Slash(ctx, srcConsAddr, math.LegacyMustNewDecFromStr("0.5"), srcPower, srcInfractionHeight) + require.NoError(t, err) + + // assert invariants to ensure correctness + _, stop := stakingkeeper.AllInvariants(stakingKeeper)(ctx) + require.False(t, stop) + + _, stop = bankkeeper.AllInvariants(bankKeeper)(ctx) + require.False(t, stop) + + _, stop = distributionkeeper.AllInvariants(distrKeeper)(ctx) + require.False(t, stop) +} diff --git a/x/staking/keeper/slash.go b/x/staking/keeper/slash.go index 5179752a5b58..c7623d6b5c37 100644 --- a/x/staking/keeper/slash.go +++ b/x/staking/keeper/slash.go @@ -373,13 +373,12 @@ func (k Keeper) SlashRedelegation(ctx context.Context, srcValidator types.Valida if err != nil { return math.ZeroInt(), err } - sharesToUnbond, err := dstVal.SharesFromTokensTruncated(slashAmount) - if err != nil { - return math.ZeroInt(), err - } + sharesToUnbond, err := dstVal.SharesFromTokensTruncated(slashAmount) if sharesToUnbond.IsZero() { continue + } else if err != nil { + return math.ZeroInt(), err } // Delegations can be dynamic hence need to be looked up on every redelegation entry loop. From b536d1153202867cab457316155d7b68be57c04e Mon Sep 17 00:00:00 2001 From: Aaron Craelius Date: Wed, 24 Jul 2024 13:27:30 +0200 Subject: [PATCH 39/50] docs: update ADR 054 (go semver compatible SDK modules) (#21009) --- .../adr-054-semver-compatible-modules.md | 306 +++--------------- 1 file changed, 51 insertions(+), 255 deletions(-) diff --git a/docs/architecture/adr-054-semver-compatible-modules.md b/docs/architecture/adr-054-semver-compatible-modules.md index 8173b9a20c69..5dc0a666f69b 100644 --- a/docs/architecture/adr-054-semver-compatible-modules.md +++ b/docs/architecture/adr-054-semver-compatible-modules.md @@ -3,6 +3,7 @@ ## Changelog * 2022-04-27: First draft +* 2024-07-21: Second draft ## Status @@ -286,7 +287,29 @@ the [protoreflect API](https://pkg.go.dev/google.golang.org/protobuf/reflect/pro to ensure that no fields unknown to the receiving module are set. This could result in an undesirable performance hit depending on how complex this logic is. -### Approach B) Changes to Generated Code +#### No New Fields in Existing Protobuf Messages + +An alternative to addressing minor version incompatibilities as described above is disallowing new fields in existing protobuf messages. While this is more restrictive, it simplifies versioning and eliminates the need for runtime unknown field checking. In addition, this approach would simplify cross language communication with the proposed [RFC 002: Zero Copy Encoding](../rfc/rfc-002-zero-copy-encoding.md). So, while it is rather restrictive, it has gained a fair amount of support. + +Although disallowing new fields may seem overly restrictive, there is a straightforward way to work around it using protobuf `oneof`s. Because `oneof` and `enum` cases must get processed through a `switch` statement, adding new cases is not problematic because any unknown cases can be handled by a `default` clause. The router layer wouldn't need to do unknown field filtering for these because the `switch` statement is a native way to do this. If we needed to add new fields to `MsgDoSomething` from above and retain the possibility of adding more new fields in the future, we could do something like this: + +```protobuf +message MsgDoSomethingWithOptions { + string sender = 1; + uint64 amount = 2; + repeated MsgDoSomethingOption options = 3; +} + +message MsgDoSomethingOption { + oneof option { + Condition condition = 1; + } +} +``` + +New `oneof` cases can be added to `MsgDoSomethingOption` and this has a similar effect as adding new fields to `MsgDoSomethingWithOptions` but no new fields are needed. A similar strategy is recommended for adding variadic options to golang functions in https://go.dev/blog/module-compatibility and expanded upon in https://commandcenter.blogspot.com/2014/01/self-referential-functions-and-design.html. + +### Approach B) Changes to Generated Code to a Getter/Setter API An alternate approach to solving the versioning problem is to change how protobuf code is generated and move modules mostly or completely in the direction of inter-module communication as described @@ -429,297 +452,70 @@ Other downsides to this approach are: * doesn't get us any closer to proper object capability security (one of the goals of ADR 033) * ADR 033 needs to be done properly anyway for the set of use cases which do need it -## Decision - -The latest **DRAFT** proposal is: - -1. we are alignment on adopting [ADR 033](./adr-033-protobuf-inter-module-comm.md) not just as an addition to the - framework, but as a core replacement to the keeper paradigm entirely. -2. the ADR 033 inter-module router will accommodate any variation of approach (A) or (B) given the following rules: - a. if the client type is the same as the server type then pass it directly through, - b. if both client and server use the zero-copy generated code wrappers (which still need to be defined), then pass - the memory buffers from one wrapper to the other, or - c. marshal/unmarshal types between client and server. - -This approach will allow for both maximal correctness and enable a clear path to enabling modules within in other -languages, possibly executed within a WASM VM. - -### Minor API Revisions - -To declare minor API revisions of proto files, we propose the following guidelines (which were already documented -in [cosmos.app.v1alpha module options](https://github.com/cosmos/cosmos-sdk/blob/main/proto/cosmos/app/v1alpha1/module.proto): - -* proto packages which are revised from their initial version (considered revision `0`) should include a `package` -* comment in some .proto file containing the test `Revision N` at the start of a comment line where `N` is the current -revision number. -* all fields, messages, etc. added in a version beyond the initial revision should add a comment at the start of a -comment line of the form `Since: Revision N` where `N` is the non-zero revision it was added. +### Approach E) Use Structural Typing in Inter-module APIs, Avoid New Fields on Messages -It is advised that there is a 1:1 correspondence between a state machine module and versioned set of proto files -which are versioned either as a buf module a go API module or both. If the buf schema registry is used, the version of -this buf module should always be `1.N` where `N` corresponds to the package revision. Patch releases should be used when -only documentation comments are updated. It is okay to include proto packages named `v2`, `v3`, etc. in this same -`1.N` versioned buf module (ex. `cosmos.bank.v2`) as long as all these proto packages consist of a single API intended -to be served by a single SDK module. +The current non-router based approach for inter-module communication is for a module to define a `Keeper` interface and for a consumer module to define an expected keeper interface with a subset of the keeper's methods. Such an interface can allow one module to avoid a direct dependency on another module if no concrete types need to be imported from the other module. For instance, if we had a method `DoSomething(context.Context, string, uint64)` as in `foo.v1`, then a module calling `DoSomething` would not need to import `foo` directly. If, however, we had a struct parameter such as `Condition` and the new method were `DoSomethingV2(context.Context, string, uint64, foo.Condition)` then a calling module would generally need to import foo just to get a reference to the `foo.Condition` struct. -### Introspecting Minor API Revisions +Golang, however, supports both structural and nominal typing. Nominal typing means that two types equivalent if and only if they have the same name. Structural typing in golang means that two types are equivalent if they have the same structure and are unnamed. So if we defined `Condition` nominally it might look like `type Condition struct { Field1 string }` and if we defined it structurally it would look like `type Condition = struct { Field1 string }`. If `Condition` were defined structurally we could use the expected keeper approach and a calling module _would not_ need to import `foo` at all to define the `DoSomethingV2` method in its expected keeper interface. Structural typing avoids the dependency problems described above. -In order for modules to introspect the minor API revision of peer modules, we propose adding the following method -to `cosmossdk.io/core/intermodule.Client`: +We could actually extend this structural typing paradigm to protobuf generated code _if_ we disallow adding new fields to existing protobuf messages. This would be required because two struct types are only identical if their fields are identical. If even the order of fields in a struct or the struct tags change, then golang considers the structs as different types. While this is fairly restrictive, it is under consideration for approach A) and [RFC 002](../rfc/rfc-002-zero-copy-encoding.md) as well and has gained a fair amount of support. -```go -ServiceRevision(ctx context.Context, serviceName string) uint64 -``` - -Modules could all this using the service name statically generated by the go grpc code generator: - -```go -intermoduleClient.ServiceRevision(ctx, bankv1beta1.Msg_ServiceDesc.ServiceName) -``` - -In the future, we may decide to extend the code generator used for protobuf services to add a field -to client types which does this check more concisely, ex: +Small modifications to the existing pulsar code generator could potentially generate code that uses structural typing and moves the implementation of protobuf interfaces to wrapper types because unnamed structs can't define methods. Here's an example of what this might look like: ```go -package bankv1beta1 - -type MsgClient interface { - Send(context.Context, MsgSend) (MsgSendResponse, error) - ServiceRevision(context.Context) uint64 +type MsgDoSomething = struct { + Sender string + Amount uint64 } -``` - -### Unknown Field Filtering -To correctly perform [unknown field filtering](./adr-020-protobuf-transaction-encoding.md#unknown-field-filtering), -the inter-module router can do one of the following: +type MsgDoSomething_Message(*MsgDoSomething) -* use the `protoreflect` API for messages which support that -* for gogo proto messages, marshal and use the existing `codec/unknownproto` code -* for zero-copy messages, do a simple check on the highest set field number (assuming we can require that fields are - adding consecutively in increasing order) - -### `FileDescriptor` Registration - -Because a single go binary may contain different versions of the same generated protobuf code, we cannot rely on the -global protobuf registry to contain the correct `FileDescriptor`s. Because `appconfig` module configuration is itself -written in protobuf, we would like to load the `FileDescriptor`s for a module before loading a module itself. So we -will provide ways to register `FileDescriptor`s at module registration time before instantiation. We propose the -following `cosmossdk.io/core/appmodule.Option` constructors for the various cases of how `FileDescriptor`s may be -packaged: - -```go -package appmodule - -// this can be used when we are using google.golang.org/protobuf compatible generated code -// Ex: -// ProtoFiles(bankv1beta1.File_cosmos_bank_v1beta1_module_proto) -func ProtoFiles(file []protoreflect.FileDescriptor) Option {} - -// this can be used when we are using gogo proto generated code. -func GzippedProtoFiles(file [][]byte) Option {} - -// this can be used when we are using buf build to generated a pinned file descriptor -func ProtoImage(protoImage []byte) Option {} +// MsgDoSomething_Message would actually implement protobuf methods +var _ proto.Message = (*MsgDoSomething_Message)(nil) ``` -This approach allows us to support several ways protobuf files might be generated: - -* proto files generated internally to a module (use `ProtoFiles`) -* the API module approach with pinned file descriptors (use `ProtoImage`) -* gogo proto (use `GzippedProtoFiles`) - -### Module Dependency Declaration +At least at the message layer, such an API wouldn't pose a problem because the transaction decoder does message decoding and modules wouldn't need to interact with the `proto.Message` interface directly. -One risk of ADR 033 is that dependencies are called at runtime which are not present in the loaded set of SDK modules. -Also we want modules to have a way to define a minimum dependency API revision that they require. Therefore, all -modules should declare their set of dependencies upfront. These dependencies could be defined when a module is -instantiated, but ideally we know what the dependencies are before instantiation and can statically look at an app -config and determine whether the set of modules. For example, if `bar` requires `foo` revision `>= 1`, then we -should be able to know this when creating an app config with two versions of `bar` and `foo`. +In order to avoid problems with the global protobuf registry, the structural typing generated code would only register message descriptors with the global registry but not register message types. This would allow two modules to generate the same protobuf types in different packages without causing a conflict. Because the types are defined structurally, they would actually be the _same_ types but no direct import would be required. In order to ensure compatibility, when message descriptors are registered at startup, a check would be required to ensure that messages are identical (i.e. no new fields). -We propose defining these dependencies in the proto options of the module config object itself. +With this approach, a module `bar` calling module `foo` could either import `foo` directly to get its types or generate its own set of compatible types for `foo`s API. The dependency problem is essentially solved with this approach without needing any sort of special discipline around a separate API module. The main discipline would be around versioning protobuf APIs correctly and not adding new fields. -### Interface Registration - -We will also need to define how interface methods are defined on types that are serialized as `google.protobuf.Any`'s. -In light of the desire to support modules in other languages, we may want to think of solutions that will accommodate -other languages such as plugins described briefly in [ADR 033](./adr-033-protobuf-inter-module-comm.md#internal-methods). - -### Testing - -In order to ensure that modules are indeed with multiple versions of their dependencies, we plan to provide specialized -unit and integration testing infrastructure that automatically tests multiple versions of dependencies. - -#### Unit Testing - -Unit tests should be conducted inside SDK modules by mocking their dependencies. In a full ADR 033 scenario, -this means that all interaction with other modules is done via the inter-module router, so mocking of dependencies -means mocking their msg and query server implementations. We will provide both a test runner and fixture to make this -streamlined. The key thing that the test runner should do to test compatibility is to test all combinations of -dependency API revisions. This can be done by taking the file descriptors for the dependencies, parsing their comments -to determine the revisions various elements were added, and then created synthetic file descriptors for each revision -by subtracting elements that were added later. - -Here is a proposed API for the unit test runner and fixture: +Taking this approach one step further, we could potentially even define APIs that unwrap the request and response types, i.e. `DoSomething(context.Context, string, uint64) error` vs `DoSomething(context.Context, MsgDoSomething) (MsgDoSomethingResponse, error)`. Or, APIs could even be defined directly in golang and the `.proto` files plus marshaling code could be generated via `go generate`. Ex: ```go -package moduletesting - -import ( - "context" - "testing" - - "cosmossdk.io/core/intermodule" - "cosmossdk.io/depinject" - "google.golang.org/grpc" - "google.golang.org/protobuf/proto" - "google.golang.org/protobuf/reflect/protodesc" -) - -type TestFixture interface { - context.Context - intermodule.Client // for making calls to the module we're testing - BeginBlock() - EndBlock() -} +package foo -type UnitTestFixture interface { - TestFixture - grpc.ServiceRegistrar // for registering mock service implementations -} +import "context" -type UnitTestConfig struct { - ModuleConfig proto.Message // the module's config object - DepinjectConfig depinject.Config // optional additional depinject config options - DependencyFileDescriptors []protodesc.FileDescriptorProto // optional dependency file descriptors to use instead of the global registry -} +//go:generate go run github.com/cosmos/cosmos-proto/cmd/structproto -// Run runs the test function for all combinations of dependency API revisions. -func (cfg UnitTestConfig) Run(t *testing.T, f func(t *testing.T, f UnitTestFixture)) { - // ... +type Msg interface { + DoSomething(context.Context, string, uint64) error } ``` -Here is an example for testing bar calling foo which takes advantage of conditional service revisions in the expected -mock arguments: +While having the limitation of not allowing new fields to be added to existing structs, approach E) has the following benefits: +* unlike approach A), api types can be generated in the same go module, but direct imports can always be avoided +* generated client/server code could look more like regular go interfaces (without needing a set of intermediate structs) +* keeper interface defined in `.go` files could be turned into protobuf APIs (rather than needing to write `.proto` files) +* SDK modules could adopt go semantic versioning without any of the issues described above, achieving the initially stated goals of this ADR -```go -func TestBar(t *testing.T) { - UnitTestConfig{ModuleConfig: &foomodulev1.Module{}}.Run(t, func (t *testing.T, f moduletesting.UnitTestFixture) { - ctrl := gomock.NewController(t) - mockFooMsgServer := footestutil.NewMockMsgServer() - foov1.RegisterMsgServer(f, mockFooMsgServer) - barMsgClient := barv1.NewMsgClient(f) - if f.ServiceRevision(foov1.Msg_ServiceDesc.ServiceName) >= 1 { - mockFooMsgServer.EXPECT().DoSomething(gomock.Any(), &foov1.MsgDoSomething{ - ..., - Condition: ..., // condition is expected in revision >= 1 - }).Return(&foov1.MsgDoSomethingResponse{}, nil) - } else { - mockFooMsgServer.EXPECT().DoSomething(gomock.Any(), &foov1.MsgDoSomething{...}).Return(&foov1.MsgDoSomethingResponse{}, nil) - } - res, err := barMsgClient.CallFoo(f, &MsgCallFoo{}) - ... - }) -} -``` - -The unit test runner would make sure that no dependency mocks return arguments which are invalid for the service -revision being tested to ensure that modules don't incorrectly depend on functionality not present in a given revision. - -#### Integration Testing - -An integration test runner and fixture would also be provided which instead of using mocks would test actual module -dependencies in various combinations. Here is the proposed API: - -```go -type IntegrationTestFixture interface { - TestFixture -} - -type IntegrationTestConfig struct { - ModuleConfig proto.Message // the module's config object - DependencyMatrix map[string][]proto.Message // all the dependent module configs -} - -// Run runs the test function for all combinations of dependency modules. -func (cfg IntegationTestConfig) Run(t *testing.T, f func (t *testing.T, f IntegrationTestFixture)) { - // ... -} -``` - -And here is an example with foo and bar: - -```go -func TestBarIntegration(t *testing.T) { - IntegrationTestConfig{ - ModuleConfig: &barmodulev1.Module{}, - DependencyMatrix: map[string][]proto.Message{ - "runtime": []proto.Message{ // test against two versions of runtime - &runtimev1.Module{}, - &runtimev2.Module{}, - }, - "foo": []proto.Message{ // test against three versions of foo - &foomodulev1.Module{}, - &foomodulev2.Module{}, - &foomodulev3.Module{}, - } - } - }.Run(t, func (t *testing.T, f moduletesting.IntegrationTestFixture) { - barMsgClient := barv1.NewMsgClient(f) - res, err := barMsgClient.CallFoo(f, &MsgCallFoo{}) - ... - }) -} -``` +## Decision -Unlike unit tests, integration tests actually pull in other module dependencies. So that modules can be written -without direct dependencies on other modules and because golang has no concept of development dependencies, integration -tests should be written in separate go modules, ex. `example.com/bar/v2/test`. Because this paradigm uses go semantic -versioning, it is possible to build a single go module which imports 3 versions of bar and 2 versions of runtime and -can test these all together in the six various combinations of dependencies. +There has been no decision yet, and the SDK has more or less been following approach C) and official adoption of [0ver](https://0ver.org) as a policy has been discussed. The issue of decoupling modules, properly versioning protobuf types, avoiding breakage, and adopting semver continue to arise from time to time. The most serious alternatives under consideration currently are approaches A) and E). The remainder of this ADR has been left blank and will be filled in when and if there is further convergence on a solution. ## Consequences ### Backwards Compatibility -Modules which migrate fully to ADR 033 will not be compatible with existing modules which use the keeper paradigm. -As a temporary workaround we may create some wrapper types that emulate the current keeper interface to minimize -the migration overhead. - ### Positive -* we will be able to deliver interoperable semantically versioned modules which should dramatically increase the - ability of the Cosmos SDK ecosystem to iterate on new features -* it will be possible to write Cosmos SDK modules in other languages in the near future - ### Negative -* all modules will need to be refactored somewhat dramatically - ### Neutral -* the `cosmossdk.io/core/appconfig` framework will play a more central role in terms of how modules are defined, this - is likely generally a good thing but does mean additional changes for users wanting to stick to the pre-depinject way - of wiring up modules -* `depinject` is somewhat less needed or maybe even obviated because of the full ADR 033 approach. If we adopt the - core API proposed in https://github.com/cosmos/cosmos-sdk/pull/12239, then a module would probably always instantiate - itself with a method `ProvideModule(appmodule.Service) (appmodule.AppModule, error)`. There is no complex wiring of - keeper dependencies in this scenario and dependency injection may not have as much of (or any) use case. - ## Further Discussions -The decision described above is considered in draft mode and is pending final buy-in from the team and key stakeholders. -Key outstanding discussions if we do adopt that direction are: - -* how do module clients introspect dependency module API revisions -* how do modules determine a minor dependency module API revision requirement -* how do modules appropriately test compatibility with different dependency versions -* how to register and resolve interface implementations -* how do modules register their protobuf file descriptors depending on the approach they take to generated code (the - API module approach may still be viable as a supported strategy and would need pinned file descriptors) - ## References * https://github.com/cosmos/cosmos-sdk/discussions/10162 From 1f0ce2f5b534647d61b248695da3ef4bc49e5853 Mon Sep 17 00:00:00 2001 From: Alexander Peters Date: Wed, 24 Jul 2024 14:40:01 +0200 Subject: [PATCH 40/50] refactor(sims)!: Remove Baseapp from sims (#21039) --- .gitignore | 1 + CHANGELOG.md | 2 +- server/v2/cometbft/go.mod | 12 ---- server/v2/cometbft/go.sum | 47 ---------------- tests/sims/gov/operations_test.go | 5 +- types/simulation/types.go | 21 +++++-- x/accounts/defaults/lockup/go.mod | 18 ------ x/accounts/defaults/lockup/go.sum | 61 --------------------- x/auth/simulation/proposals.go | 5 +- x/auth/simulation/proposals_test.go | 2 +- x/authz/simulation/operations.go | 7 +-- x/bank/simulation/operations.go | 13 ++--- x/bank/simulation/proposals.go | 5 +- x/bank/simulation/proposals_test.go | 3 +- x/distribution/simulation/operations.go | 7 +-- x/distribution/simulation/proposals.go | 5 +- x/distribution/simulation/proposals_test.go | 3 +- x/feegrant/simulation/operations.go | 5 +- x/gov/simulation/operations.go | 38 +++++++------ x/gov/simulation/proposals.go | 5 +- x/gov/simulation/proposals_test.go | 3 +- x/group/simulation/operations.go | 29 +++++----- x/mint/simulation/proposals.go | 5 +- x/mint/simulation/proposals_test.go | 3 +- x/nft/simulation/operations.go | 3 +- x/protocolpool/simulation/operations.go | 3 +- x/protocolpool/simulation/proposals.go | 5 +- x/protocolpool/simulation/proposals_test.go | 3 +- x/simulation/params.go | 22 ++++++-- x/simulation/util.go | 3 +- x/slashing/simulation/operations.go | 3 +- x/slashing/simulation/proposals.go | 5 +- x/slashing/simulation/proposals_test.go | 3 +- x/staking/simulation/operations.go | 15 +++-- x/staking/simulation/proposals.go | 9 ++- x/staking/simulation/proposals_test.go | 16 +++--- 36 files changed, 140 insertions(+), 255 deletions(-) diff --git a/.gitignore b/.gitignore index 0fc9f902957a..bc2377793355 100644 --- a/.gitignore +++ b/.gitignore @@ -63,3 +63,4 @@ debug_container.log *.synctex.gz /x/genutil/config/priv_validator_key.json /x/genutil/data/priv_validator_state.json +simapp/simapp.test \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index be30e89daadc..b727862bd96a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -120,7 +120,7 @@ Every module contains its own CHANGELOG.md. Please refer to the module you are i * (testutil/integration) [#21006](https://github.com/cosmos/cosmos-sdk/pull/21006) Fix `NewIntegrationApp` method not writing default genesis to state ### API Breaking Changes - +* (sims) [#21039](https://github.com/cosmos/cosmos-sdk/pull/21039): Remove Baseapp from sims by a new interface `simtypes.AppEntrypoint` * (client) [#20976](https://github.com/cosmos/cosmos-sdk/pull/20976) Simplified command initialization by removing unnecessary parameters such as `txConfig` and `addressCodec`. * Remove parameter `txConfig` from `genutilcli.Commands`,`genutilcli.CommandsWithCustomMigrationMap`,`genutilcli.GenTxCmd`. * Remove parameter `addressCodec` from `genutilcli.GenTxCmd`,`genutilcli.AddGenesisAccountCmd`,`stakingcli.BuildCreateValidatorMsg`. diff --git a/server/v2/cometbft/go.mod b/server/v2/cometbft/go.mod index c10a4dc2725b..d76a77456e91 100644 --- a/server/v2/cometbft/go.mod +++ b/server/v2/cometbft/go.mod @@ -52,7 +52,6 @@ require ( cosmossdk.io/depinject v1.0.0 // indirect cosmossdk.io/log v1.3.1 // indirect cosmossdk.io/math v1.3.0 // indirect - cosmossdk.io/schema v0.1.1 // indirect cosmossdk.io/store v1.1.1-0.20240418092142-896cdf1971bc // indirect cosmossdk.io/x/auth v0.0.0-00010101000000-000000000000 // indirect cosmossdk.io/x/bank v0.0.0-20240226161501-23359a0b6d91 // indirect @@ -61,9 +60,7 @@ require ( filippo.io/edwards25519 v1.1.0 // indirect github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 // indirect github.com/99designs/keyring v1.2.2 // indirect - github.com/DataDog/datadog-go v4.8.3+incompatible // indirect github.com/DataDog/zstd v1.5.5 // indirect - github.com/Microsoft/go-winio v0.6.1 // indirect github.com/beorn7/perks v1.0.1 // indirect github.com/bgentry/speakeasy v0.2.0 // indirect github.com/btcsuite/btcd/btcec/v2 v2.3.3 // indirect @@ -78,7 +75,6 @@ require ( github.com/cosmos/cosmos-db v1.0.2 // indirect github.com/cosmos/crypto v0.1.2 // indirect github.com/cosmos/go-bip39 v1.0.0 // indirect - github.com/cosmos/gogogateway v1.2.0 // indirect github.com/cosmos/iavl v1.2.0 // indirect github.com/cosmos/ics23/go v0.10.0 // indirect github.com/cosmos/ledger-cosmos-go v0.13.3 // indirect @@ -91,7 +87,6 @@ require ( github.com/dvsekhvalnov/jose2go v1.6.0 // indirect github.com/emicklei/dot v1.6.2 // indirect github.com/fatih/color v1.17.0 // indirect - github.com/felixge/httpsnoop v1.0.4 // indirect github.com/fsnotify/fsnotify v1.7.0 // indirect github.com/getsentry/sentry-go v0.27.0 // indirect github.com/go-kit/kit v0.13.0 // indirect @@ -99,7 +94,6 @@ require ( github.com/go-logfmt/logfmt v0.6.0 // indirect github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2 // indirect github.com/gofrs/uuid v4.4.0+incompatible // indirect - github.com/gogo/googleapis v1.4.1 // indirect github.com/gogo/protobuf v1.3.2 // indirect github.com/golang/glog v1.2.0 // indirect github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect @@ -108,10 +102,7 @@ require ( github.com/google/flatbuffers v2.0.8+incompatible // indirect github.com/google/go-cmp v0.6.0 // indirect github.com/google/orderedcode v0.0.1 // indirect - github.com/gorilla/handlers v1.5.2 // indirect - github.com/gorilla/mux v1.8.1 // indirect github.com/gorilla/websocket v1.5.3 // indirect - github.com/grpc-ecosystem/go-grpc-middleware v1.4.0 // indirect github.com/gsterjov/go-libsecret v0.0.0-20161001094733-a6f4afe4910c // indirect github.com/hashicorp/go-hclog v1.6.3 // indirect github.com/hashicorp/go-immutable-radix v1.3.1 // indirect @@ -122,7 +113,6 @@ require ( github.com/hashicorp/hcl v1.0.0 // indirect github.com/hashicorp/yamux v0.1.1 // indirect github.com/hdevalence/ed25519consensus v0.2.0 // indirect - github.com/huandu/skiplist v1.2.0 // indirect github.com/iancoleman/strcase v0.3.0 // indirect github.com/inconshreveable/mousetrap v1.1.0 // indirect github.com/jmhodges/levigo v1.0.0 // indirect @@ -175,13 +165,11 @@ require ( go.uber.org/multierr v1.11.0 // indirect golang.org/x/crypto v0.25.0 // indirect golang.org/x/exp v0.0.0-20240531132922-fd00a4e0eefc // indirect - golang.org/x/mod v0.17.0 // indirect golang.org/x/net v0.27.0 // indirect golang.org/x/sync v0.7.0 // indirect golang.org/x/sys v0.22.0 // indirect golang.org/x/term v0.22.0 // indirect golang.org/x/text v0.16.0 // indirect - golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d // indirect google.golang.org/genproto v0.0.0-20240227224415-6ceb2ff114de // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20240709173604-40e1e62336c5 // indirect gopkg.in/ini.v1 v1.67.0 // indirect diff --git a/server/v2/cometbft/go.sum b/server/v2/cometbft/go.sum index 7ba20e510178..8b5334c6af42 100644 --- a/server/v2/cometbft/go.sum +++ b/server/v2/cometbft/go.sum @@ -41,7 +41,6 @@ github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuy github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY= -github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= @@ -69,12 +68,6 @@ github.com/circonus-labs/circonus-gometrics v2.3.1+incompatible/go.mod h1:nmEj6D github.com/circonus-labs/circonusllhist v0.1.3/go.mod h1:kMXHVDlOchFAehlya5ePtbp5jckzBHf4XRpQvBOLI+I= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= -github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= -github.com/cncf/udpa/go v0.0.0-20210930031921-04548b0d99d4/go.mod h1:6pvJx4me5XPnfI9Z40ddWsdw2W/uZgQLFXToKeRcDiI= -github.com/cncf/xds/go v0.0.0-20210805033703-aa0b78936158/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= -github.com/cncf/xds/go v0.0.0-20210922020428-25de7278fc84/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= -github.com/cncf/xds/go v0.0.0-20211001041855-01bcc9b48dfe/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= -github.com/cncf/xds/go v0.0.0-20211011173535-cb28da3451f1/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= github.com/cockroachdb/datadriven v1.0.3-0.20230413201302-be42291fc80f h1:otljaYPt5hWxV3MUfO5dFPFiOXg9CyG5/kCfayTqsJ4= github.com/cockroachdb/datadriven v1.0.3-0.20230413201302-be42291fc80f/go.mod h1:a9RdTaap04u637JoCzcUoIcDmvwSUtcUFtT/C3kJlTU= github.com/cockroachdb/errors v1.11.1 h1:xSEW75zKaKCWzR3OfxXUxgrk/NtT4G1MiOv5lWZazG8= @@ -108,7 +101,6 @@ github.com/cosmos/go-bip39 v1.0.0 h1:pcomnQdrdH22njcAatO0yWojsUnCO3y2tNoV1cb6hHY github.com/cosmos/go-bip39 v1.0.0/go.mod h1:RNJv0H/pOIVgxw6KS7QeX2a0Uo0aKUlfhZ4xuwvCdJw= github.com/cosmos/gogogateway v1.2.0 h1:Ae/OivNhp8DqBi/sh2A8a1D0y638GpL3tkmLQAiKxTE= github.com/cosmos/gogogateway v1.2.0/go.mod h1:iQpLkGWxYcnCdz5iAdLcRBSw3h7NXeOkZ4GUkT+tbFI= -github.com/cosmos/gogoproto v1.4.2/go.mod h1:cLxOsn1ljAHSV527CHOtaIP91kK6cCrZETRBrkzItWU= github.com/cosmos/gogoproto v1.5.0 h1:SDVwzEqZDDBoslaeZg+dGE55hdzHfgUA40pEanMh52o= github.com/cosmos/gogoproto v1.5.0/go.mod h1:iUM31aofn3ymidYG6bUR5ZFrk+Om8p5s754eMUcyp8I= github.com/cosmos/iavl v1.2.0 h1:kVxTmjTh4k0Dh1VNL046v6BXqKziqMDzxo93oh3kOfM= @@ -150,9 +142,6 @@ github.com/emicklei/dot v1.6.2/go.mod h1:DeV7GvQtIw4h2u73RKBkkFdvVAz0D9fzeJrgPW6 github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= -github.com/envoyproxy/go-control-plane v0.9.9-0.20201210154907-fd9021fe5dad/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk= -github.com/envoyproxy/go-control-plane v0.9.10-0.20210907150352-cf90f659a021/go.mod h1:AFq3mo9L8Lqqiid3OhADV3RfLJnjiw63cSpi+fDTRC0= -github.com/envoyproxy/go-control-plane v0.10.2-0.20220325020618-49ff273808a1/go.mod h1:KJwIaB5Mv44NWtYuAOFCVOjcI94vtpEz2JU/D2v6IjE= github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk= github.com/fatih/color v1.17.0 h1:GlRw1BRJxkpqUCBKzKOw098ed57fEsKeNjpTe3cSjK4= @@ -177,12 +166,10 @@ github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2 github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= github.com/go-kit/kit v0.13.0 h1:OoneCcHKHQ03LfBpoQCUfCluwd2Vt3ohz+kvbJneZAU= github.com/go-kit/kit v0.13.0/go.mod h1:phqEHMMUbyrCFCTgH48JueqrM3md2HcAZ8N3XE4FKDg= -github.com/go-kit/log v0.1.0/go.mod h1:zbhenjAZHb184qTLMA9ZjW7ThYL0H2mk7Q6pNt4vbaY= github.com/go-kit/log v0.2.1 h1:MRVx0/zhvdseW+Gza6N9rVzU/IVzaeE1SFI4raAhmBU= github.com/go-kit/log v0.2.1/go.mod h1:NwTd00d/i8cPZ3xOwwiv2PO5MOcx78fFErGNcVmBjv0= github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE= github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk= -github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A= github.com/go-logfmt/logfmt v0.6.0 h1:wGYYu3uicYdqXVgoYbvnkrPVXkuLM1p1ifugDMEdRi4= github.com/go-logfmt/logfmt v0.6.0/go.mod h1:WYhtIu8zTZfxdn5+rREduYbwxfcBr/Vr6KEVveWlfTs= github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= @@ -192,11 +179,9 @@ github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2/go.mod h1:bBOAhwG1umN6 github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= github.com/gofrs/uuid v4.4.0+incompatible h1:3qXRTX8/NbyulANqlc0lchS1gqAVxRgsuW1YrTJupqA= github.com/gofrs/uuid v4.4.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM= -github.com/gogo/googleapis v1.4.1-0.20201022092350-68b0159b7869/go.mod h1:5YRNX2z1oM5gXdAkurHa942MDgEJyk02w4OecKY87+c= github.com/gogo/googleapis v1.4.1 h1:1Yx4Myt7BxzvUr5ldGSbwYiZG6t9wGBZ+8/fX3Wvtq0= github.com/gogo/googleapis v1.4.1/go.mod h1:2lpHqI5OcWCtVElxXnPt+s8oJvMpySlOyM6xDCrzib4= github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= -github.com/gogo/protobuf v1.3.1/go.mod h1:SlYgWuQ5SjCEi6WLHjHCa1yvBfUnHcTbrrZtXPKa29o= github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= @@ -238,7 +223,6 @@ github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/ github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.3/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= @@ -288,8 +272,6 @@ github.com/hashicorp/yamux v0.1.1/go.mod h1:CtWFDAQgb7dxtzFs4tWbplKIe2jSi3+5vKbg github.com/hdevalence/ed25519consensus v0.2.0 h1:37ICyZqdyj0lAZ8P4D1d1id3HqbbG1N3iBb1Tb4rdcU= github.com/hdevalence/ed25519consensus v0.2.0/go.mod h1:w3BHWjwJbFU29IRHL1Iqkw3sus+7FctEyM4RqDxYNzo= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= -github.com/huandu/go-assert v1.1.5 h1:fjemmA7sSfYHJD7CUqs9qTwwfdNAx7/j2/ZlHXzNB3c= -github.com/huandu/go-assert v1.1.5/go.mod h1:yOLvuqZwmcHIC5rIzrBhT7D3Q9c3GFnd0JrPVhn/06U= github.com/huandu/skiplist v1.2.0 h1:gox56QD77HzSC0w+Ws3MH3iie755GBJU1OER3h5VsYw= github.com/huandu/skiplist v1.2.0/go.mod h1:7v3iFjLcSAzO4fN5B8dvebvo/qsfumiLiDXMrPiHF9w= github.com/iancoleman/strcase v0.3.0 h1:nTXanmYxhfFAMjZL34Ov6gkzEsSJZ5DbhxWjvSASxEI= @@ -304,7 +286,6 @@ github.com/jmhodges/levigo v1.0.0/go.mod h1:Q6Qx+uH3RAqyK4rFQroq9RL7mdkABMcfhEI+ github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= github.com/json-iterator/go v1.1.9/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= -github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQLJ+jE2L00= github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/klauspost/compress v1.17.8 h1:YcnTYrq7MikUT7k0Yb5eceMmALQPYBW/Xltxn0NAMnU= @@ -378,7 +359,6 @@ github.com/opencontainers/image-spec v1.1.0-rc5 h1:Ygwkfw9bpDvs+c9E34SdgGOj41dX/ github.com/opencontainers/image-spec v1.1.0-rc5/go.mod h1:X4pATf0uXsnn3g5aiGIsVnJBR4mxhKzfwmvK/B2NTm8= github.com/opencontainers/runc v1.1.12 h1:BOIssBaW1La0/qbNZHXOOa71dZfZEQOzW7dqQf3phss= github.com/opencontainers/runc v1.1.12/go.mod h1:S+lQwSfncpBha7XTy/5lBwWgm5+y5Ma/O44Ekby9FK8= -github.com/opentracing/opentracing-go v1.1.0/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o= github.com/ory/dockertest v3.3.5+incompatible h1:iLLK6SQwIhcbrG783Dghaaa3WPzGc+4Emza6EbVUUGA= github.com/ory/dockertest v3.3.5+incompatible/go.mod h1:1vX4m9wsvi00u5bseYwXaSnhNrne+V0E6LAcBILJdPs= github.com/pascaldekloe/goe v0.1.0 h1:cBOtyMzM9HTpWjXfbbunk26uA6nG3a8n06Wieeh0MwY= @@ -463,7 +443,6 @@ github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UV github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.2/go.mod h1:R6va5+xMeoiuVRoj+gSkQ7d3FALtqAAGI1FQKckRals= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= @@ -496,13 +475,8 @@ go.etcd.io/bbolt v1.4.0-alpha.0.0.20240404170359-43604f3112c5 h1:qxen9oVGzDdIRP6 go.etcd.io/bbolt v1.4.0-alpha.0.0.20240404170359-43604f3112c5/go.mod h1:eW0HG9/oHQhvRCvb1/pIXW4cOvtDqeQK+XSi3TnwaXY= go.opencensus.io v0.24.0 h1:y73uSU6J157QMP2kn2r30vwW1A2W2WFwSCGnAVxeaD0= go.opencensus.io v0.24.0/go.mod h1:vNK8G9p7aAivkbmorf4v+7Hgx+Zs0yY+0fOtgBfjQKo= -go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI= -go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= -go.uber.org/goleak v1.1.10/go.mod h1:8a7PlsEVH3e/a/GLqe5IIrQx6GzcnRmZEufDUTk4A7A= -go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU= go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0= go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= -go.uber.org/zap v1.18.1/go.mod h1:xg/QME4nWcxGxrpdeYfq7UvYrLh66cuVKdrbD1XF/NI= golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= @@ -516,7 +490,6 @@ golang.org/x/exp v0.0.0-20240531132922-fd00a4e0eefc/go.mod h1:XtvwrStGgqGPLc4cjQ golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= -golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.17.0 h1:zY54UmvipHiNd+pm+m0x9KhZ9hl1/7QNMyxXbc6ICqA= @@ -536,7 +509,6 @@ golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7/go.mod h1:qpuaurCH72eLCgpAm/ golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= -golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= golang.org/x/net v0.0.0-20210428140749-89ef3d95e781/go.mod h1:OJAsFXCWl8Ukc7SiCT/9KSuxbyM7479/AVlXFRxuMCk= golang.org/x/net v0.0.0-20220225172249-27dd8689420f/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= golang.org/x/net v0.0.0-20220607020251-c690dde0001d/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= @@ -572,16 +544,11 @@ golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210112080510-489259a85091/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20211025201205-69cdffdb9359/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220315194320-039c03cc5b86/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220412211240-33da011f77ad/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220503163025-988cb79eb6c6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= @@ -597,18 +564,15 @@ golang.org/x/term v0.22.0 h1:BbsgPEJULsl2fV/AT3v15Mjva5yXKQDyKf+TbDz7QJk= golang.org/x/term v0.22.0/go.mod h1:F3qCibpT5AMpCRfhfT53vVJwhLtIVHhB9XDjfFvnMI4= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4= golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20181030221726-6c7e314b6563/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= -golang.org/x/tools v0.0.0-20191108193012-7d206e10da11/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20201224043029-2b0845dc783e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= @@ -625,10 +589,8 @@ google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7 google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= google.golang.org/genproto v0.0.0-20180831171423-11092d34479b/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= -google.golang.org/genproto v0.0.0-20200423170343-7949de9c1215/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= google.golang.org/genproto v0.0.0-20200513103714-09dca8ec2884/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo= -google.golang.org/genproto v0.0.0-20220314164441-57ef72a4c106/go.mod h1:hAL49I2IFola2sVEjAn7MEwsja0xp51I0tlGAf9hz4E= google.golang.org/genproto v0.0.0-20240227224415-6ceb2ff114de h1:F6qOa9AZTYJXOUEr4jDysRDLrm4PHePlge4v4TGAlxY= google.golang.org/genproto v0.0.0-20240227224415-6ceb2ff114de/go.mod h1:VUhTRKeHn9wwcdrk73nvdC9gF178Tzhmt/qyaFcPLSo= google.golang.org/genproto/googleapis/api v0.0.0-20240318140521-94a12d6c2237 h1:RFiFrvy37/mpSpdySBDrUdipW/dHwsRwh3J3+A9VgT4= @@ -639,12 +601,8 @@ google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZi google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY= google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= -google.golang.org/grpc v1.29.1/go.mod h1:itym6AZVZYACWQqET3MqgPpjcuV5QH3BxFS3IjizoKk= google.golang.org/grpc v1.33.1/go.mod h1:fr5YgcSWrqhRRxogOsw7RzIpsmvOZ6IcH4kBYTpR3n0= google.golang.org/grpc v1.33.2/go.mod h1:JMHMWHQWaTccqQQlmk3MJZS+GWXOdAesneDmEnv2fbc= -google.golang.org/grpc v1.36.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU= -google.golang.org/grpc v1.45.0/go.mod h1:lN7owxKUQEqMfSyQikvvk5tf/6zMPsrK+ONuO11+0rQ= -google.golang.org/grpc v1.49.0/go.mod h1:ZgQEeidpAuNRZ8iRrlBKXZQP1ghovWIVhdJRyCDK+GI= google.golang.org/grpc v1.64.1 h1:LKtvyfbX3UGVPFcGqJ9ItpVWW6oN/2XqTxfAnwRRXiA= google.golang.org/grpc v1.64.1/go.mod h1:hiQF4LFZelK2WKaP6W0L92zGHtiQdZxk8CrSdvyjeP0= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= @@ -658,13 +616,10 @@ google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpAD google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg= google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw= gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20200902074654-038fdea0a05b/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= @@ -679,11 +634,9 @@ gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.3/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.5/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gotest.tools/v3 v3.5.1 h1:EENdUnS3pdur5nybKYIh2Vfgc8IUNBjxDPSjtiJcOzU= diff --git a/tests/sims/gov/operations_test.go b/tests/sims/gov/operations_test.go index 7e4b6a27ea69..93159e6f5206 100644 --- a/tests/sims/gov/operations_test.go +++ b/tests/sims/gov/operations_test.go @@ -1,6 +1,7 @@ package simulation_test import ( + "context" "fmt" "math/rand" "testing" @@ -56,8 +57,8 @@ func (m MockWeightedProposals) DefaultWeight() int { return m.n } -func (m MockWeightedProposals) MsgSimulatorFn() simtypes.MsgSimulatorFn { - return func(r *rand.Rand, _ []simtypes.Account, _ address.Codec) (sdk.Msg, error) { +func (m MockWeightedProposals) MsgSimulatorFn() simtypes.MsgSimulatorFnX { + return func(_ context.Context, r *rand.Rand, _ []simtypes.Account, _ address.Codec) (sdk.Msg, error) { return nil, nil } } diff --git a/types/simulation/types.go b/types/simulation/types.go index da9c67332f6c..c576b2885d06 100644 --- a/types/simulation/types.go +++ b/types/simulation/types.go @@ -1,6 +1,7 @@ package simulation import ( + "context" "encoding/json" "fmt" "math/rand" @@ -10,11 +11,15 @@ import ( "cosmossdk.io/core/address" - "github.com/cosmos/cosmos-sdk/baseapp" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/kv" ) +// AppEntrypoint defines the method for delivering simulation TX to the app. This is implemented by *Baseapp +type AppEntrypoint interface { + SimDeliver(_txEncoder sdk.TxEncoder, tx sdk.Tx) (sdk.GasInfo, *sdk.Result, error) +} + // Deprecated: Use WeightedProposalMsg instead. type WeightedProposalContent interface { AppParamsKey() string // key used to retrieve the value of the weight from the simulation application params @@ -36,12 +41,16 @@ type Content interface { } type WeightedProposalMsg interface { - AppParamsKey() string // key used to retrieve the value of the weight from the simulation application params - DefaultWeight() int // default weight - MsgSimulatorFn() MsgSimulatorFn // msg simulator function + AppParamsKey() string // key used to retrieve the value of the weight from the simulation application params + DefaultWeight() int // default weight + MsgSimulatorFn() MsgSimulatorFnX // msg simulator function } -type MsgSimulatorFn func(r *rand.Rand, accs []Account, cdc address.Codec) (sdk.Msg, error) +type ( + // Deprecated: use MsgSimulatorFnX + MsgSimulatorFn func(r *rand.Rand, accs []Account, cdc address.Codec) (sdk.Msg, error) + MsgSimulatorFnX func(ctx context.Context, r *rand.Rand, accs []Account, cdc address.Codec) (sdk.Msg, error) +) type SimValFn func(r *rand.Rand) string @@ -66,7 +75,7 @@ type WeightedOperation interface { // // Operations can optionally provide a list of "FutureOperations" to run later // These will be ran at the beginning of the corresponding block. -type Operation func(r *rand.Rand, app *baseapp.BaseApp, +type Operation func(r *rand.Rand, app AppEntrypoint, ctx sdk.Context, accounts []Account, chainID string) ( OperationMsg OperationMsg, futureOps []FutureOperation, err error) diff --git a/x/accounts/defaults/lockup/go.mod b/x/accounts/defaults/lockup/go.mod index 3b29b91f3acd..b5a31476bd55 100644 --- a/x/accounts/defaults/lockup/go.mod +++ b/x/accounts/defaults/lockup/go.mod @@ -19,7 +19,6 @@ require ( buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.34.2-20240701160653-fedbb9acfd2f.2 // indirect cosmossdk.io/core/testing v0.0.0-00010101000000-000000000000 // indirect cosmossdk.io/depinject v1.0.0 // indirect - cosmossdk.io/schema v0.1.1 // indirect github.com/cometbft/cometbft/api v1.0.0-rc.1 // indirect github.com/cosmos/crypto v0.1.2 // indirect github.com/dgraph-io/badger/v4 v4.2.0 // indirect @@ -42,9 +41,7 @@ require ( filippo.io/edwards25519 v1.1.0 // indirect github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 // indirect github.com/99designs/keyring v1.2.2 // indirect - github.com/DataDog/datadog-go v4.8.3+incompatible // indirect github.com/DataDog/zstd v1.5.5 // indirect - github.com/Microsoft/go-winio v0.6.1 // indirect github.com/beorn7/perks v1.0.1 // indirect github.com/bgentry/speakeasy v0.2.0 // indirect github.com/btcsuite/btcd/btcec/v2 v2.3.3 // indirect @@ -60,7 +57,6 @@ require ( github.com/cosmos/cosmos-db v1.0.2 // indirect github.com/cosmos/cosmos-proto v1.0.0-beta.5 github.com/cosmos/go-bip39 v1.0.0 // indirect - github.com/cosmos/gogogateway v1.2.0 // indirect github.com/cosmos/iavl v1.2.0 // indirect github.com/cosmos/ics23/go v0.10.0 // indirect github.com/cosmos/ledger-cosmos-go v0.13.3 // indirect @@ -71,36 +67,26 @@ require ( github.com/dustin/go-humanize v1.0.1 // indirect github.com/dvsekhvalnov/jose2go v1.6.0 // indirect github.com/emicklei/dot v1.6.2 // indirect - github.com/fatih/color v1.17.0 // indirect - github.com/felixge/httpsnoop v1.0.4 // indirect github.com/fsnotify/fsnotify v1.7.0 // indirect github.com/getsentry/sentry-go v0.27.0 // indirect github.com/go-kit/kit v0.13.0 // indirect github.com/go-kit/log v0.2.1 // indirect github.com/go-logfmt/logfmt v0.6.0 // indirect github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2 // indirect - github.com/gogo/googleapis v1.4.1 // indirect github.com/gogo/protobuf v1.3.2 // indirect github.com/golang/glog v1.2.0 // indirect github.com/golang/protobuf v1.5.4 github.com/golang/snappy v0.0.4 // indirect github.com/google/btree v1.1.2 // indirect github.com/google/go-cmp v0.6.0 // indirect - github.com/gorilla/handlers v1.5.2 // indirect - github.com/gorilla/mux v1.8.1 // indirect github.com/gorilla/websocket v1.5.3 // indirect - github.com/grpc-ecosystem/go-grpc-middleware v1.4.0 // indirect github.com/grpc-ecosystem/grpc-gateway v1.16.0 // indirect github.com/gsterjov/go-libsecret v0.0.0-20161001094733-a6f4afe4910c // indirect - github.com/hashicorp/go-hclog v1.6.3 // indirect github.com/hashicorp/go-immutable-radix v1.3.1 // indirect github.com/hashicorp/go-metrics v0.5.3 // indirect - github.com/hashicorp/go-plugin v1.6.1 // indirect github.com/hashicorp/golang-lru v1.0.2 // indirect github.com/hashicorp/hcl v1.0.0 // indirect - github.com/hashicorp/yamux v0.1.1 // indirect github.com/hdevalence/ed25519consensus v0.2.0 // indirect - github.com/huandu/skiplist v1.2.0 // indirect github.com/iancoleman/strcase v0.3.0 // indirect github.com/inconshreveable/mousetrap v1.1.0 // indirect github.com/jmhodges/levigo v1.0.0 // indirect @@ -112,11 +98,9 @@ require ( github.com/magiconair/properties v1.8.7 // indirect github.com/mattn/go-colorable v0.1.13 // indirect github.com/mattn/go-isatty v0.0.20 // indirect - github.com/mitchellh/go-testing-interface v1.14.1 // indirect github.com/mitchellh/mapstructure v1.5.0 // indirect github.com/mtibben/percent v0.2.1 // indirect github.com/oasisprotocol/curve25519-voi v0.0.0-20230904125328-1f23a7beb09a // indirect - github.com/oklog/run v1.1.0 // indirect github.com/pelletier/go-toml/v2 v2.2.2 // indirect github.com/petermattis/goid v0.0.0-20240327183114-c42a807a84ba // indirect github.com/pkg/errors v0.9.1 // indirect @@ -150,13 +134,11 @@ require ( go.uber.org/multierr v1.11.0 // indirect golang.org/x/crypto v0.25.0 // indirect golang.org/x/exp v0.0.0-20240531132922-fd00a4e0eefc // indirect - golang.org/x/mod v0.17.0 // indirect golang.org/x/net v0.27.0 // indirect golang.org/x/sync v0.7.0 // indirect golang.org/x/sys v0.22.0 // indirect golang.org/x/term v0.22.0 // indirect golang.org/x/text v0.16.0 // indirect - golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d // indirect google.golang.org/genproto v0.0.0-20240227224415-6ceb2ff114de // indirect google.golang.org/genproto/googleapis/api v0.0.0-20240318140521-94a12d6c2237 // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20240709173604-40e1e62336c5 // indirect diff --git a/x/accounts/defaults/lockup/go.sum b/x/accounts/defaults/lockup/go.sum index 7c088816d9a3..0e5cfe5cf50d 100644 --- a/x/accounts/defaults/lockup/go.sum +++ b/x/accounts/defaults/lockup/go.sum @@ -37,7 +37,6 @@ github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuy github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY= -github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= @@ -50,8 +49,6 @@ github.com/btcsuite/btcd/btcutil v1.1.5 h1:+wER79R5670vs/ZusMTF1yTcRYE5GUsFbdjdi github.com/btcsuite/btcd/btcutil v1.1.5/go.mod h1:PSZZ4UitpLBWzxGd5VGOrLnmOjtPP/a6HaFo12zMs00= github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1 h1:q0rUy8C/TYNBQS1+CGKw68tLOFYSNEs0TFnxxnS9+4U= github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1/go.mod h1:7SFka0XMvUgj3hfZtydOrQY2mwhPclbT2snogU7SQQc= -github.com/bufbuild/protocompile v0.4.0 h1:LbFKd2XowZvQ/kajzguUp2DC9UEIQhIq77fZZlaQsNA= -github.com/bufbuild/protocompile v0.4.0/go.mod h1:3v93+mbWn/v3xzN+31nwkJfrEpAUwp+BagBSZWx+TP8= github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs= @@ -63,12 +60,6 @@ github.com/circonus-labs/circonus-gometrics v2.3.1+incompatible/go.mod h1:nmEj6D github.com/circonus-labs/circonusllhist v0.1.3/go.mod h1:kMXHVDlOchFAehlya5ePtbp5jckzBHf4XRpQvBOLI+I= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= -github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= -github.com/cncf/udpa/go v0.0.0-20210930031921-04548b0d99d4/go.mod h1:6pvJx4me5XPnfI9Z40ddWsdw2W/uZgQLFXToKeRcDiI= -github.com/cncf/xds/go v0.0.0-20210805033703-aa0b78936158/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= -github.com/cncf/xds/go v0.0.0-20210922020428-25de7278fc84/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= -github.com/cncf/xds/go v0.0.0-20211001041855-01bcc9b48dfe/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= -github.com/cncf/xds/go v0.0.0-20211011173535-cb28da3451f1/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= github.com/cockroachdb/datadriven v1.0.3-0.20230413201302-be42291fc80f h1:otljaYPt5hWxV3MUfO5dFPFiOXg9CyG5/kCfayTqsJ4= github.com/cockroachdb/datadriven v1.0.3-0.20230413201302-be42291fc80f/go.mod h1:a9RdTaap04u637JoCzcUoIcDmvwSUtcUFtT/C3kJlTU= github.com/cockroachdb/errors v1.11.1 h1:xSEW75zKaKCWzR3OfxXUxgrk/NtT4G1MiOv5lWZazG8= @@ -100,7 +91,6 @@ github.com/cosmos/go-bip39 v1.0.0 h1:pcomnQdrdH22njcAatO0yWojsUnCO3y2tNoV1cb6hHY github.com/cosmos/go-bip39 v1.0.0/go.mod h1:RNJv0H/pOIVgxw6KS7QeX2a0Uo0aKUlfhZ4xuwvCdJw= github.com/cosmos/gogogateway v1.2.0 h1:Ae/OivNhp8DqBi/sh2A8a1D0y638GpL3tkmLQAiKxTE= github.com/cosmos/gogogateway v1.2.0/go.mod h1:iQpLkGWxYcnCdz5iAdLcRBSw3h7NXeOkZ4GUkT+tbFI= -github.com/cosmos/gogoproto v1.4.2/go.mod h1:cLxOsn1ljAHSV527CHOtaIP91kK6cCrZETRBrkzItWU= github.com/cosmos/gogoproto v1.5.0 h1:SDVwzEqZDDBoslaeZg+dGE55hdzHfgUA40pEanMh52o= github.com/cosmos/gogoproto v1.5.0/go.mod h1:iUM31aofn3ymidYG6bUR5ZFrk+Om8p5s754eMUcyp8I= github.com/cosmos/iavl v1.2.0 h1:kVxTmjTh4k0Dh1VNL046v6BXqKziqMDzxo93oh3kOfM= @@ -138,11 +128,7 @@ github.com/emicklei/dot v1.6.2/go.mod h1:DeV7GvQtIw4h2u73RKBkkFdvVAz0D9fzeJrgPW6 github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= -github.com/envoyproxy/go-control-plane v0.9.9-0.20201210154907-fd9021fe5dad/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk= -github.com/envoyproxy/go-control-plane v0.9.10-0.20210907150352-cf90f659a021/go.mod h1:AFq3mo9L8Lqqiid3OhADV3RfLJnjiw63cSpi+fDTRC0= -github.com/envoyproxy/go-control-plane v0.10.2-0.20220325020618-49ff273808a1/go.mod h1:KJwIaB5Mv44NWtYuAOFCVOjcI94vtpEz2JU/D2v6IjE= github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= -github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk= github.com/fatih/color v1.17.0 h1:GlRw1BRJxkpqUCBKzKOw098ed57fEsKeNjpTe3cSjK4= github.com/fatih/color v1.17.0/go.mod h1:YZ7TlrGPkiz6ku9fK3TLD/pl3CpsiFyu8N92HLgmosI= github.com/felixge/httpsnoop v1.0.4 h1:NFTV2Zj1bL4mc9sqWACXbQFVBBg2W3GPvqp8/ESS2Wg= @@ -165,12 +151,10 @@ github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2 github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= github.com/go-kit/kit v0.13.0 h1:OoneCcHKHQ03LfBpoQCUfCluwd2Vt3ohz+kvbJneZAU= github.com/go-kit/kit v0.13.0/go.mod h1:phqEHMMUbyrCFCTgH48JueqrM3md2HcAZ8N3XE4FKDg= -github.com/go-kit/log v0.1.0/go.mod h1:zbhenjAZHb184qTLMA9ZjW7ThYL0H2mk7Q6pNt4vbaY= github.com/go-kit/log v0.2.1 h1:MRVx0/zhvdseW+Gza6N9rVzU/IVzaeE1SFI4raAhmBU= github.com/go-kit/log v0.2.1/go.mod h1:NwTd00d/i8cPZ3xOwwiv2PO5MOcx78fFErGNcVmBjv0= github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE= github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk= -github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A= github.com/go-logfmt/logfmt v0.6.0 h1:wGYYu3uicYdqXVgoYbvnkrPVXkuLM1p1ifugDMEdRi4= github.com/go-logfmt/logfmt v0.6.0/go.mod h1:WYhtIu8zTZfxdn5+rREduYbwxfcBr/Vr6KEVveWlfTs= github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= @@ -180,11 +164,9 @@ github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2/go.mod h1:bBOAhwG1umN6 github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= github.com/gofrs/uuid v4.4.0+incompatible h1:3qXRTX8/NbyulANqlc0lchS1gqAVxRgsuW1YrTJupqA= github.com/gofrs/uuid v4.4.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM= -github.com/gogo/googleapis v1.4.1-0.20201022092350-68b0159b7869/go.mod h1:5YRNX2z1oM5gXdAkurHa942MDgEJyk02w4OecKY87+c= github.com/gogo/googleapis v1.4.1 h1:1Yx4Myt7BxzvUr5ldGSbwYiZG6t9wGBZ+8/fX3Wvtq0= github.com/gogo/googleapis v1.4.1/go.mod h1:2lpHqI5OcWCtVElxXnPt+s8oJvMpySlOyM6xDCrzib4= github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= -github.com/gogo/protobuf v1.3.1/go.mod h1:SlYgWuQ5SjCEi6WLHjHCa1yvBfUnHcTbrrZtXPKa29o= github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= @@ -226,7 +208,6 @@ github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/ github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.3/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= @@ -276,8 +257,6 @@ github.com/hashicorp/yamux v0.1.1/go.mod h1:CtWFDAQgb7dxtzFs4tWbplKIe2jSi3+5vKbg github.com/hdevalence/ed25519consensus v0.2.0 h1:37ICyZqdyj0lAZ8P4D1d1id3HqbbG1N3iBb1Tb4rdcU= github.com/hdevalence/ed25519consensus v0.2.0/go.mod h1:w3BHWjwJbFU29IRHL1Iqkw3sus+7FctEyM4RqDxYNzo= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= -github.com/huandu/go-assert v1.1.5 h1:fjemmA7sSfYHJD7CUqs9qTwwfdNAx7/j2/ZlHXzNB3c= -github.com/huandu/go-assert v1.1.5/go.mod h1:yOLvuqZwmcHIC5rIzrBhT7D3Q9c3GFnd0JrPVhn/06U= github.com/huandu/skiplist v1.2.0 h1:gox56QD77HzSC0w+Ws3MH3iie755GBJU1OER3h5VsYw= github.com/huandu/skiplist v1.2.0/go.mod h1:7v3iFjLcSAzO4fN5B8dvebvo/qsfumiLiDXMrPiHF9w= github.com/iancoleman/strcase v0.3.0 h1:nTXanmYxhfFAMjZL34Ov6gkzEsSJZ5DbhxWjvSASxEI= @@ -285,14 +264,11 @@ github.com/iancoleman/strcase v0.3.0/go.mod h1:iwCmte+B7n89clKwxIoIXy/HfoL7AsD47 github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8= github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= -github.com/jhump/protoreflect v1.15.3 h1:6SFRuqU45u9hIZPJAoZ8c28T3nK64BNdp9w6jFonzls= -github.com/jhump/protoreflect v1.15.3/go.mod h1:4ORHmSBmlCW8fh3xHmJMGyul1zNqZK4Elxc8qKP+p1k= github.com/jmhodges/levigo v1.0.0 h1:q5EC36kV79HWeTBWsod3mG11EgStG3qArTKcvlksN1U= github.com/jmhodges/levigo v1.0.0/go.mod h1:Q6Qx+uH3RAqyK4rFQroq9RL7mdkABMcfhEI+nNuzMJQ= github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= github.com/json-iterator/go v1.1.9/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= -github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQLJ+jE2L00= github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/klauspost/compress v1.17.8 h1:YcnTYrq7MikUT7k0Yb5eceMmALQPYBW/Xltxn0NAMnU= @@ -314,12 +290,8 @@ github.com/linxGnu/grocksdb v1.8.14 h1:HTgyYalNwBSG/1qCQUIott44wU5b2Y9Kr3z7SK5Of github.com/linxGnu/grocksdb v1.8.14/go.mod h1:QYiYypR2d4v63Wj1adOOfzglnoII0gLj3PNh4fZkcFA= github.com/magiconair/properties v1.8.7 h1:IeQXZAiQcpL9mgcAe1Nu6cX9LLw6ExEHKjN0VQdvPDY= github.com/magiconair/properties v1.8.7/go.mod h1:Dhd985XPs7jluiymwWYZ0G4Z61jb3vdS329zhj2hYo0= -github.com/mattn/go-colorable v0.1.9/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= -github.com/mattn/go-colorable v0.1.12/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4= github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= -github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= -github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94= github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= @@ -360,7 +332,6 @@ github.com/onsi/gomega v1.17.0/go.mod h1:HnhC7FXeEQY45zxNK3PPoIUhzk/80Xly9PcubAl github.com/onsi/gomega v1.19.0/go.mod h1:LY+I3pBVzYsTBU1AnDwOSxaYi9WoWiqgwooUqq9yPro= github.com/onsi/gomega v1.28.1 h1:MijcGUbfYuznzK/5R4CPNoUP/9Xvuo20sXfEm6XxoTA= github.com/onsi/gomega v1.28.1/go.mod h1:9sxs+SwGrKI0+PWe4Fxa9tFQQBG5xSsSbMXOI8PPpoQ= -github.com/opentracing/opentracing-go v1.1.0/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o= github.com/pascaldekloe/goe v0.1.0 h1:cBOtyMzM9HTpWjXfbbunk26uA6nG3a8n06Wieeh0MwY= github.com/pascaldekloe/goe v0.1.0/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= github.com/pelletier/go-toml/v2 v2.2.2 h1:aYUidT7k73Pcl9nb2gScu7NSrKCSHIDE89b3+6Wq+LM= @@ -441,7 +412,6 @@ github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UV github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.2/go.mod h1:R6va5+xMeoiuVRoj+gSkQ7d3FALtqAAGI1FQKckRals= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= @@ -474,13 +444,8 @@ go.etcd.io/bbolt v1.4.0-alpha.0.0.20240404170359-43604f3112c5 h1:qxen9oVGzDdIRP6 go.etcd.io/bbolt v1.4.0-alpha.0.0.20240404170359-43604f3112c5/go.mod h1:eW0HG9/oHQhvRCvb1/pIXW4cOvtDqeQK+XSi3TnwaXY= go.opencensus.io v0.24.0 h1:y73uSU6J157QMP2kn2r30vwW1A2W2WFwSCGnAVxeaD0= go.opencensus.io v0.24.0/go.mod h1:vNK8G9p7aAivkbmorf4v+7Hgx+Zs0yY+0fOtgBfjQKo= -go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI= -go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= -go.uber.org/goleak v1.1.10/go.mod h1:8a7PlsEVH3e/a/GLqe5IIrQx6GzcnRmZEufDUTk4A7A= -go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU= go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0= go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= -go.uber.org/zap v1.18.1/go.mod h1:xg/QME4nWcxGxrpdeYfq7UvYrLh66cuVKdrbD1XF/NI= golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= @@ -494,7 +459,6 @@ golang.org/x/exp v0.0.0-20240531132922-fd00a4e0eefc/go.mod h1:XtvwrStGgqGPLc4cjQ golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= -golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.17.0 h1:zY54UmvipHiNd+pm+m0x9KhZ9hl1/7QNMyxXbc6ICqA= @@ -514,7 +478,6 @@ golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7/go.mod h1:qpuaurCH72eLCgpAm/ golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= -golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= golang.org/x/net v0.0.0-20210428140749-89ef3d95e781/go.mod h1:OJAsFXCWl8Ukc7SiCT/9KSuxbyM7479/AVlXFRxuMCk= golang.org/x/net v0.0.0-20220225172249-27dd8689420f/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= golang.org/x/net v0.0.0-20220607020251-c690dde0001d/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= @@ -542,25 +505,15 @@ golang.org/x/sys v0.0.0-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200122134326-e047566fdf82/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210112080510-489259a85091/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20211025201205-69cdffdb9359/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220315194320-039c03cc5b86/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220412211240-33da011f77ad/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220503163025-988cb79eb6c6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20221010170243-090e33056c14/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= @@ -574,18 +527,15 @@ golang.org/x/term v0.22.0 h1:BbsgPEJULsl2fV/AT3v15Mjva5yXKQDyKf+TbDz7QJk= golang.org/x/term v0.22.0/go.mod h1:F3qCibpT5AMpCRfhfT53vVJwhLtIVHhB9XDjfFvnMI4= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4= golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20181030221726-6c7e314b6563/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= -golang.org/x/tools v0.0.0-20191108193012-7d206e10da11/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20201224043029-2b0845dc783e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= @@ -602,10 +552,8 @@ google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7 google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= google.golang.org/genproto v0.0.0-20180831171423-11092d34479b/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= -google.golang.org/genproto v0.0.0-20200423170343-7949de9c1215/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= google.golang.org/genproto v0.0.0-20200513103714-09dca8ec2884/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo= -google.golang.org/genproto v0.0.0-20220314164441-57ef72a4c106/go.mod h1:hAL49I2IFola2sVEjAn7MEwsja0xp51I0tlGAf9hz4E= google.golang.org/genproto v0.0.0-20240227224415-6ceb2ff114de h1:F6qOa9AZTYJXOUEr4jDysRDLrm4PHePlge4v4TGAlxY= google.golang.org/genproto v0.0.0-20240227224415-6ceb2ff114de/go.mod h1:VUhTRKeHn9wwcdrk73nvdC9gF178Tzhmt/qyaFcPLSo= google.golang.org/genproto/googleapis/api v0.0.0-20240318140521-94a12d6c2237 h1:RFiFrvy37/mpSpdySBDrUdipW/dHwsRwh3J3+A9VgT4= @@ -616,12 +564,8 @@ google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZi google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY= google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= -google.golang.org/grpc v1.29.1/go.mod h1:itym6AZVZYACWQqET3MqgPpjcuV5QH3BxFS3IjizoKk= google.golang.org/grpc v1.33.1/go.mod h1:fr5YgcSWrqhRRxogOsw7RzIpsmvOZ6IcH4kBYTpR3n0= google.golang.org/grpc v1.33.2/go.mod h1:JMHMWHQWaTccqQQlmk3MJZS+GWXOdAesneDmEnv2fbc= -google.golang.org/grpc v1.36.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU= -google.golang.org/grpc v1.45.0/go.mod h1:lN7owxKUQEqMfSyQikvvk5tf/6zMPsrK+ONuO11+0rQ= -google.golang.org/grpc v1.49.0/go.mod h1:ZgQEeidpAuNRZ8iRrlBKXZQP1ghovWIVhdJRyCDK+GI= google.golang.org/grpc v1.64.1 h1:LKtvyfbX3UGVPFcGqJ9ItpVWW6oN/2XqTxfAnwRRXiA= google.golang.org/grpc v1.64.1/go.mod h1:hiQF4LFZelK2WKaP6W0L92zGHtiQdZxk8CrSdvyjeP0= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= @@ -635,13 +579,10 @@ google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpAD google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg= google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw= gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20200902074654-038fdea0a05b/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= @@ -656,11 +597,9 @@ gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.3/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.5/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gotest.tools/v3 v3.5.1 h1:EENdUnS3pdur5nybKYIh2Vfgc8IUNBjxDPSjtiJcOzU= diff --git a/x/auth/simulation/proposals.go b/x/auth/simulation/proposals.go index 244acb1975e1..78a5c09e2f86 100644 --- a/x/auth/simulation/proposals.go +++ b/x/auth/simulation/proposals.go @@ -1,6 +1,7 @@ package simulation import ( + "context" "math/rand" coreaddress "cosmossdk.io/core/address" @@ -22,7 +23,7 @@ const ( // ProposalMsgs defines the module weighted proposals' contents func ProposalMsgs() []simtypes.WeightedProposalMsg { return []simtypes.WeightedProposalMsg{ - simulation.NewWeightedProposalMsg( + simulation.NewWeightedProposalMsgX( OpWeightMsgUpdateParams, DefaultWeightMsgUpdateParams, SimulateMsgUpdateParams, @@ -31,7 +32,7 @@ func ProposalMsgs() []simtypes.WeightedProposalMsg { } // SimulateMsgUpdateParams returns a random MsgUpdateParams -func SimulateMsgUpdateParams(r *rand.Rand, _ []simtypes.Account, _ coreaddress.Codec) (sdk.Msg, error) { +func SimulateMsgUpdateParams(_ context.Context, r *rand.Rand, _ []simtypes.Account, _ coreaddress.Codec) (sdk.Msg, error) { // use the default gov module account address as authority var authority sdk.AccAddress = address.Module("gov") diff --git a/x/auth/simulation/proposals_test.go b/x/auth/simulation/proposals_test.go index bbe53b58ef48..b5fc4cf8aa5d 100644 --- a/x/auth/simulation/proposals_test.go +++ b/x/auth/simulation/proposals_test.go @@ -32,7 +32,7 @@ func TestProposalMsgs(t *testing.T) { assert.Equal(t, simulation.OpWeightMsgUpdateParams, w0.AppParamsKey()) assert.Equal(t, simulation.DefaultWeightMsgUpdateParams, w0.DefaultWeight()) - msg, err := w0.MsgSimulatorFn()(r, accounts, codectestutil.CodecOptions{}.GetAddressCodec()) + msg, err := w0.MsgSimulatorFn()(sdk.Context{}, r, accounts, codectestutil.CodecOptions{}.GetAddressCodec()) assert.NilError(t, err) msgUpdateParams, ok := msg.(*types.MsgUpdateParams) assert.Assert(t, ok) diff --git a/x/authz/simulation/operations.go b/x/authz/simulation/operations.go index 374a451cfc23..4c7c085d3b70 100644 --- a/x/authz/simulation/operations.go +++ b/x/authz/simulation/operations.go @@ -16,7 +16,6 @@ import ( "cosmossdk.io/x/authz/keeper" banktype "cosmossdk.io/x/bank/types" - "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" cdctypes "github.com/cosmos/cosmos-sdk/codec/types" @@ -103,7 +102,7 @@ func SimulateMsgGrant( _ keeper.Keeper, ) simtypes.Operation { return func( - r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accs []simtypes.Account, chainID string, + r *rand.Rand, app simtypes.AppEntrypoint, ctx sdk.Context, accs []simtypes.Account, chainID string, ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { granter, _ := simtypes.RandomAcc(r, accs) grantee, _ := simtypes.RandomAcc(r, accs) @@ -184,7 +183,7 @@ func SimulateMsgRevoke( k keeper.Keeper, ) simtypes.Operation { return func( - r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accs []simtypes.Account, chainID string, + r *rand.Rand, app simtypes.AppEntrypoint, ctx sdk.Context, accs []simtypes.Account, chainID string, ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { var granterAddr, granteeAddr sdk.AccAddress var grant authz.Grant @@ -265,7 +264,7 @@ func SimulateMsgExec( unpacker gogoprotoany.AnyUnpacker, ) simtypes.Operation { return func( - r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accs []simtypes.Account, chainID string, + r *rand.Rand, app simtypes.AppEntrypoint, ctx sdk.Context, accs []simtypes.Account, chainID string, ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { var granterAddr sdk.AccAddress var granteeAddr sdk.AccAddress diff --git a/x/bank/simulation/operations.go b/x/bank/simulation/operations.go index b3933b6d01e1..d662687cfe07 100644 --- a/x/bank/simulation/operations.go +++ b/x/bank/simulation/operations.go @@ -6,7 +6,6 @@ import ( "cosmossdk.io/x/bank/keeper" "cosmossdk.io/x/bank/types" - "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" @@ -63,7 +62,7 @@ func SimulateMsgSend( bk keeper.Keeper, ) simtypes.Operation { return func( - r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, + r *rand.Rand, app simtypes.AppEntrypoint, ctx sdk.Context, accs []simtypes.Account, chainID string, ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { msgType := sdk.MsgTypeURL(&types.MsgSend{}) @@ -110,7 +109,7 @@ func SimulateMsgSendToModuleAccount( moduleAccount int, ) simtypes.Operation { return func( - r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, + r *rand.Rand, app simtypes.AppEntrypoint, ctx sdk.Context, accs []simtypes.Account, chainID string, ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { msgType := sdk.MsgTypeURL(&types.MsgSend{}) @@ -146,7 +145,7 @@ func SimulateMsgSendToModuleAccount( // sendMsgSend sends a transaction with a MsgSend from a provided random account. func sendMsgSend( - r *rand.Rand, app *baseapp.BaseApp, + r *rand.Rand, app simtypes.AppEntrypoint, txGen client.TxConfig, bk keeper.Keeper, ak types.AccountKeeper, msg *types.MsgSend, ctx sdk.Context, chainID string, privkeys []cryptotypes.PrivKey, @@ -198,7 +197,7 @@ func sendMsgSend( // all accounts in msg fields exist in state func SimulateMsgMultiSend(txGen client.TxConfig, ak types.AccountKeeper, bk keeper.Keeper) simtypes.Operation { return func( - r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, + r *rand.Rand, app simtypes.AppEntrypoint, ctx sdk.Context, accs []simtypes.Account, chainID string, ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { msgType := sdk.MsgTypeURL(&types.MsgMultiSend{}) @@ -302,7 +301,7 @@ func SimulateMsgMultiSendToModuleAccount( moduleAccount int, ) simtypes.Operation { return func( - r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, + r *rand.Rand, app simtypes.AppEntrypoint, ctx sdk.Context, accs []simtypes.Account, chainID string, ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { msgType := sdk.MsgTypeURL(&types.MsgMultiSend{}) @@ -370,7 +369,7 @@ func SimulateMsgMultiSendToModuleAccount( // sendMsgMultiSend sends a transaction with a MsgMultiSend from a provided random // account. func sendMsgMultiSend( - r *rand.Rand, app *baseapp.BaseApp, + r *rand.Rand, app simtypes.AppEntrypoint, txGen client.TxConfig, bk keeper.Keeper, ak types.AccountKeeper, msg *types.MsgMultiSend, ctx sdk.Context, chainID string, privkeys []cryptotypes.PrivKey, diff --git a/x/bank/simulation/proposals.go b/x/bank/simulation/proposals.go index 7e2683fed6cb..ec9f637240d9 100644 --- a/x/bank/simulation/proposals.go +++ b/x/bank/simulation/proposals.go @@ -1,6 +1,7 @@ package simulation import ( + "context" "math/rand" coreaddress "cosmossdk.io/core/address" @@ -22,7 +23,7 @@ const ( // ProposalMsgs defines the module weighted proposals' contents func ProposalMsgs() []simtypes.WeightedProposalMsg { return []simtypes.WeightedProposalMsg{ - simulation.NewWeightedProposalMsg( + simulation.NewWeightedProposalMsgX( OpWeightMsgUpdateParams, DefaultWeightMsgUpdateParams, SimulateMsgUpdateParams, @@ -31,7 +32,7 @@ func ProposalMsgs() []simtypes.WeightedProposalMsg { } // SimulateMsgUpdateParams returns a random MsgUpdateParams -func SimulateMsgUpdateParams(r *rand.Rand, _ []simtypes.Account, ac coreaddress.Codec) (sdk.Msg, error) { +func SimulateMsgUpdateParams(_ context.Context, r *rand.Rand, _ []simtypes.Account, ac coreaddress.Codec) (sdk.Msg, error) { // use the default gov module account address as authority authority, err := ac.BytesToString(address.Module("gov")) if err != nil { diff --git a/x/bank/simulation/proposals_test.go b/x/bank/simulation/proposals_test.go index 3d60a17bbb91..50d7fc0ad5d3 100644 --- a/x/bank/simulation/proposals_test.go +++ b/x/bank/simulation/proposals_test.go @@ -1,6 +1,7 @@ package simulation_test import ( + "context" "math/rand" "testing" @@ -33,7 +34,7 @@ func TestProposalMsgs(t *testing.T) { assert.Equal(t, simulation.OpWeightMsgUpdateParams, w0.AppParamsKey()) assert.Equal(t, simulation.DefaultWeightMsgUpdateParams, w0.DefaultWeight()) - msg, err := w0.MsgSimulatorFn()(r, accounts, ac) + msg, err := w0.MsgSimulatorFn()(context.Background(), r, accounts, ac) assert.NilError(t, err) msgUpdateParams, ok := msg.(*types.MsgUpdateParams) assert.Assert(t, ok) diff --git a/x/distribution/simulation/operations.go b/x/distribution/simulation/operations.go index 7b210bdf95ee..4b067cbe7174 100644 --- a/x/distribution/simulation/operations.go +++ b/x/distribution/simulation/operations.go @@ -10,7 +10,6 @@ import ( "cosmossdk.io/x/distribution/keeper" "cosmossdk.io/x/distribution/types" - "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/testutil" @@ -74,7 +73,7 @@ func WeightedOperations( // SimulateMsgSetWithdrawAddress generates a MsgSetWithdrawAddress with random values. func SimulateMsgSetWithdrawAddress(txConfig client.TxConfig, ak types.AccountKeeper, bk types.BankKeeper, k keeper.Keeper) simtypes.Operation { return func( - r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accs []simtypes.Account, chainID string, + r *rand.Rand, app simtypes.AppEntrypoint, ctx sdk.Context, accs []simtypes.Account, chainID string, ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { isWithdrawAddrEnabled, err := k.GetWithdrawAddrEnabled(ctx) if err != nil { @@ -123,7 +122,7 @@ func SimulateMsgSetWithdrawAddress(txConfig client.TxConfig, ak types.AccountKee // SimulateMsgWithdrawDelegatorReward generates a MsgWithdrawDelegatorReward with random values. func SimulateMsgWithdrawDelegatorReward(txConfig client.TxConfig, ak types.AccountKeeper, bk types.BankKeeper, k keeper.Keeper, sk types.StakingKeeper) simtypes.Operation { return func( - r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accs []simtypes.Account, chainID string, + r *rand.Rand, app simtypes.AppEntrypoint, ctx sdk.Context, accs []simtypes.Account, chainID string, ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { simAccount, _ := simtypes.RandomAcc(r, accs) delegations, err := sk.GetAllDelegatorDelegations(ctx, simAccount.Address) @@ -191,7 +190,7 @@ func SimulateMsgWithdrawDelegatorReward(txConfig client.TxConfig, ak types.Accou // SimulateMsgWithdrawValidatorCommission generates a MsgWithdrawValidatorCommission with random values. func SimulateMsgWithdrawValidatorCommission(txConfig client.TxConfig, ak types.AccountKeeper, bk types.BankKeeper, k keeper.Keeper, sk types.StakingKeeper) simtypes.Operation { return func( - r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accs []simtypes.Account, chainID string, + r *rand.Rand, app simtypes.AppEntrypoint, ctx sdk.Context, accs []simtypes.Account, chainID string, ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { msgType := sdk.MsgTypeURL(&types.MsgWithdrawValidatorCommission{}) diff --git a/x/distribution/simulation/proposals.go b/x/distribution/simulation/proposals.go index 98592d1f8e5f..3d9dfe6bd900 100644 --- a/x/distribution/simulation/proposals.go +++ b/x/distribution/simulation/proposals.go @@ -1,6 +1,7 @@ package simulation import ( + "context" "math/rand" coreaddress "cosmossdk.io/core/address" @@ -23,7 +24,7 @@ const ( // ProposalMsgs defines the module weighted proposals' contents func ProposalMsgs() []simtypes.WeightedProposalMsg { return []simtypes.WeightedProposalMsg{ - simulation.NewWeightedProposalMsg( + simulation.NewWeightedProposalMsgX( OpWeightMsgUpdateParams, DefaultWeightMsgUpdateParams, SimulateMsgUpdateParams, @@ -32,7 +33,7 @@ func ProposalMsgs() []simtypes.WeightedProposalMsg { } // SimulateMsgUpdateParams returns a random MsgUpdateParams -func SimulateMsgUpdateParams(r *rand.Rand, _ []simtypes.Account, cdc coreaddress.Codec) (sdk.Msg, error) { +func SimulateMsgUpdateParams(_ context.Context, r *rand.Rand, _ []simtypes.Account, cdc coreaddress.Codec) (sdk.Msg, error) { // use the default gov module account address as authority var authority sdk.AccAddress = address.Module("gov") diff --git a/x/distribution/simulation/proposals_test.go b/x/distribution/simulation/proposals_test.go index 7903be80eb62..ce792ea856e4 100644 --- a/x/distribution/simulation/proposals_test.go +++ b/x/distribution/simulation/proposals_test.go @@ -1,6 +1,7 @@ package simulation_test import ( + "context" "math/rand" "testing" @@ -33,7 +34,7 @@ func TestProposalMsgs(t *testing.T) { assert.Equal(t, simulation.OpWeightMsgUpdateParams, w0.AppParamsKey()) assert.Equal(t, simulation.DefaultWeightMsgUpdateParams, w0.DefaultWeight()) - msg, err := w0.MsgSimulatorFn()(r, accounts, addressCodec) + msg, err := w0.MsgSimulatorFn()(context.Background(), r, accounts, addressCodec) assert.NilError(t, err) msgUpdateParams, ok := msg.(*types.MsgUpdateParams) assert.Assert(t, ok) diff --git a/x/feegrant/simulation/operations.go b/x/feegrant/simulation/operations.go index c82677d4fa09..59c3d0d7df69 100644 --- a/x/feegrant/simulation/operations.go +++ b/x/feegrant/simulation/operations.go @@ -7,7 +7,6 @@ import ( "cosmossdk.io/x/feegrant" "cosmossdk.io/x/feegrant/keeper" - "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" codectypes "github.com/cosmos/cosmos-sdk/codec/types" @@ -79,7 +78,7 @@ func SimulateMsgGrantAllowance( k keeper.Keeper, ) simtypes.Operation { return func( - r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accs []simtypes.Account, chainID string, + r *rand.Rand, app simtypes.AppEntrypoint, ctx sdk.Context, accs []simtypes.Account, chainID string, ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { granter, _ := simtypes.RandomAcc(r, accs) grantee, _ := simtypes.RandomAcc(r, accs) @@ -143,7 +142,7 @@ func SimulateMsgRevokeAllowance( k keeper.Keeper, ) simtypes.Operation { return func( - r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accs []simtypes.Account, chainID string, + r *rand.Rand, app simtypes.AppEntrypoint, ctx sdk.Context, accs []simtypes.Account, chainID string, ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { hasGrant := false diff --git a/x/gov/simulation/operations.go b/x/gov/simulation/operations.go index a8e47b279443..a2749acb8cb3 100644 --- a/x/gov/simulation/operations.go +++ b/x/gov/simulation/operations.go @@ -11,7 +11,6 @@ import ( "cosmossdk.io/x/gov/types" v1 "cosmossdk.io/x/gov/types/v1" - "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/client" simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims" sdk "github.com/cosmos/cosmos-sdk/types" @@ -171,12 +170,12 @@ func SimulateMsgSubmitProposal( ak types.AccountKeeper, bk types.BankKeeper, k *keeper.Keeper, - msgSim simtypes.MsgSimulatorFn, + msgSim simtypes.MsgSimulatorFnX, ) simtypes.Operation { - return func(r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accs []simtypes.Account, chainID string, + return func(r *rand.Rand, app simtypes.AppEntrypoint, ctx sdk.Context, accs []simtypes.Account, chainID string, ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { msgs := []sdk.Msg{} - proposalMsg, err := msgSim(r, accs, ak.AddressCodec()) + proposalMsg, err := msgSim(ctx, r, accs, ak.AddressCodec()) if err != nil { return simtypes.OperationMsg{}, nil, err } @@ -198,7 +197,7 @@ func SimulateMsgSubmitLegacyProposal( k *keeper.Keeper, contentSim simtypes.ContentSimulatorFn, //nolint:staticcheck // used for legacy testing ) simtypes.Operation { - return func(r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accs []simtypes.Account, chainID string, + return func(r *rand.Rand, app simtypes.AppEntrypoint, ctx sdk.Context, accs []simtypes.Account, chainID string, ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { // 1) submit proposal now content := contentSim(r, ctx, accs) @@ -249,7 +248,7 @@ func simulateMsgSubmitProposal( return func( r *rand.Rand, - app *baseapp.BaseApp, + app simtypes.AppEntrypoint, ctx sdk.Context, accs []simtypes.Account, chainID string, @@ -327,16 +326,19 @@ func simulateMsgSubmitProposal( whoVotes = whoVotes[:numVotes] params, _ := k.Params.Get(ctx) votingPeriod := params.VotingPeriod - - fops := make([]simtypes.FutureOperation, numVotes+1) - for i := 0; i < numVotes; i++ { - whenVote := ctx.HeaderInfo().Time.Add(time.Duration(r.Int63n(int64(votingPeriod.Seconds()))) * time.Second) - fops[i] = simtypes.FutureOperation{ - BlockTime: whenVote, - Op: operationSimulateMsgVote(txGen, ak, bk, k, accs[whoVotes[i]], int64(proposalID), nil), + var fops []simtypes.FutureOperation + if false { // future ops deactivated because they were not implemented correct in the framework before and flood the system now + fops = make([]simtypes.FutureOperation, numVotes+1) + for i := 0; i < numVotes; i++ { + whenVote := ctx.HeaderInfo().Time.Add(time.Duration(r.Int63n(int64(votingPeriod.Seconds()))) * time.Second) + fops[i] = simtypes.FutureOperation{ + BlockTime: whenVote, + Op: func(r *rand.Rand, app simtypes.AppEntrypoint, ctx sdk.Context, accounts []simtypes.Account, chainID string) (OperationMsg simtypes.OperationMsg, futureOps []simtypes.FutureOperation, err error) { + return operationSimulateMsgVote(txGen, ak, bk, k, accs[whoVotes[i]], int64(proposalID), nil)(r, app, ctx, accounts, chainID) + }, + } } } - return opMsg, fops, nil } } @@ -350,7 +352,7 @@ func SimulateMsgDeposit( s *SharedState, ) simtypes.Operation { return func( - r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, + r *rand.Rand, app simtypes.AppEntrypoint, ctx sdk.Context, accs []simtypes.Account, chainID string, ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { simAccount, _ := simtypes.RandomAcc(r, accs) @@ -429,7 +431,7 @@ func operationSimulateMsgVote( s *SharedState, ) simtypes.Operation { return func( - r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, + r *rand.Rand, app simtypes.AppEntrypoint, ctx sdk.Context, accs []simtypes.Account, chainID string, ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { if simAccount.Equals(simtypes.Account{}) { @@ -498,7 +500,7 @@ func operationSimulateMsgVoteWeighted( s *SharedState, ) simtypes.Operation { return func( - r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, + r *rand.Rand, app simtypes.AppEntrypoint, ctx sdk.Context, accs []simtypes.Account, chainID string, ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { if simAccount.Equals(simtypes.Account{}) { @@ -549,7 +551,7 @@ func operationSimulateMsgVoteWeighted( // SimulateMsgCancelProposal generates a MsgCancelProposal. func SimulateMsgCancelProposal(txGen client.TxConfig, ak types.AccountKeeper, bk types.BankKeeper, k *keeper.Keeper) simtypes.Operation { return func( - r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, + r *rand.Rand, app simtypes.AppEntrypoint, ctx sdk.Context, accs []simtypes.Account, chainID string, ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { simAccount := accs[0] diff --git a/x/gov/simulation/proposals.go b/x/gov/simulation/proposals.go index bc508cce4ebb..c53d024b13a5 100644 --- a/x/gov/simulation/proposals.go +++ b/x/gov/simulation/proposals.go @@ -1,6 +1,7 @@ package simulation import ( + "context" "math/rand" coreaddress "cosmossdk.io/core/address" @@ -17,7 +18,7 @@ const OpWeightSubmitTextProposal = "op_weight_submit_text_proposal" // ProposalMsgs defines the module weighted proposals' contents func ProposalMsgs() []simtypes.WeightedProposalMsg { return []simtypes.WeightedProposalMsg{ - simulation.NewWeightedProposalMsg( + simulation.NewWeightedProposalMsgX( OpWeightSubmitTextProposal, DefaultWeightTextProposal, SimulateTextProposal, @@ -27,7 +28,7 @@ func ProposalMsgs() []simtypes.WeightedProposalMsg { // SimulateTextProposal returns a random text proposal content. // A text proposal is a proposal that contains no msgs. -func SimulateTextProposal(r *rand.Rand, _ []simtypes.Account, _ coreaddress.Codec) (sdk.Msg, error) { +func SimulateTextProposal(_ context.Context, r *rand.Rand, _ []simtypes.Account, _ coreaddress.Codec) (sdk.Msg, error) { return nil, nil } diff --git a/x/gov/simulation/proposals_test.go b/x/gov/simulation/proposals_test.go index 41a4068e7bb3..939103c75ea9 100644 --- a/x/gov/simulation/proposals_test.go +++ b/x/gov/simulation/proposals_test.go @@ -1,6 +1,7 @@ package simulation_test import ( + "context" "math/rand" "testing" @@ -30,7 +31,7 @@ func TestProposalMsgs(t *testing.T) { assert.Equal(t, simulation.OpWeightSubmitTextProposal, w0.AppParamsKey()) assert.Equal(t, simulation.DefaultWeightTextProposal, w0.DefaultWeight()) - msg, err := w0.MsgSimulatorFn()(r, accounts, codectestutil.CodecOptions{}.GetAddressCodec()) + msg, err := w0.MsgSimulatorFn()(context.Background(), r, accounts, codectestutil.CodecOptions{}.GetAddressCodec()) assert.NilError(t, err) assert.Assert(t, msg == nil) } diff --git a/x/group/simulation/operations.go b/x/group/simulation/operations.go index d0eb1b8f7989..bab0939fddaf 100644 --- a/x/group/simulation/operations.go +++ b/x/group/simulation/operations.go @@ -14,7 +14,6 @@ import ( "cosmossdk.io/x/group" "cosmossdk.io/x/group/keeper" - "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" cdctypes "github.com/cosmos/cosmos-sdk/codec/types" @@ -250,7 +249,7 @@ func SimulateMsgCreateGroup( bk group.BankKeeper, ) simtypes.Operation { return func( - r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accounts []simtypes.Account, chainID string, + r *rand.Rand, app simtypes.AppEntrypoint, ctx sdk.Context, accounts []simtypes.Account, chainID string, ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { acc, _ := simtypes.RandomAcc(r, accounts) account := ak.GetAccount(ctx, acc.Address) @@ -303,7 +302,7 @@ func SimulateMsgCreateGroupWithPolicy( bk group.BankKeeper, ) simtypes.Operation { return func( - r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accounts []simtypes.Account, chainID string, + r *rand.Rand, app simtypes.AppEntrypoint, ctx sdk.Context, accounts []simtypes.Account, chainID string, ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { acc, _ := simtypes.RandomAcc(r, accounts) account := ak.GetAccount(ctx, acc.Address) @@ -375,7 +374,7 @@ func SimulateMsgCreateGroupPolicy( s *SharedState, ) simtypes.Operation { return func( - r *rand.Rand, app *baseapp.BaseApp, sdkCtx sdk.Context, accounts []simtypes.Account, chainID string, + r *rand.Rand, app simtypes.AppEntrypoint, sdkCtx sdk.Context, accounts []simtypes.Account, chainID string, ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { groupInfo, acc, account, err := randomGroup(r, k, ak, sdkCtx, accounts, s) if err != nil { @@ -447,7 +446,7 @@ func SimulateMsgSubmitProposal( s *SharedState, ) simtypes.Operation { return func( - r *rand.Rand, app *baseapp.BaseApp, sdkCtx sdk.Context, accounts []simtypes.Account, chainID string, + r *rand.Rand, app simtypes.AppEntrypoint, sdkCtx sdk.Context, accounts []simtypes.Account, chainID string, ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { g, groupPolicy, _, _, err := randomGroupPolicy(r, k, ak, sdkCtx, accounts, s) if err != nil { @@ -534,7 +533,7 @@ func SimulateMsgUpdateGroupAdmin( s *SharedState, ) simtypes.Operation { return func( - r *rand.Rand, app *baseapp.BaseApp, sdkCtx sdk.Context, accounts []simtypes.Account, chainID string, + r *rand.Rand, app simtypes.AppEntrypoint, sdkCtx sdk.Context, accounts []simtypes.Account, chainID string, ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { groupInfo, acc, account, err := randomGroup(r, k, ak, sdkCtx, accounts, s) if err != nil { @@ -608,7 +607,7 @@ func SimulateMsgUpdateGroupMetadata( s *SharedState, ) simtypes.Operation { return func( - r *rand.Rand, app *baseapp.BaseApp, sdkCtx sdk.Context, accounts []simtypes.Account, chainID string, + r *rand.Rand, app simtypes.AppEntrypoint, sdkCtx sdk.Context, accounts []simtypes.Account, chainID string, ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { groupInfo, acc, account, err := randomGroup(r, k, ak, sdkCtx, accounts, s) if err != nil { @@ -669,7 +668,7 @@ func SimulateMsgUpdateGroupMembers( s *SharedState, ) simtypes.Operation { return func( - r *rand.Rand, app *baseapp.BaseApp, sdkCtx sdk.Context, accounts []simtypes.Account, chainID string, + r *rand.Rand, app simtypes.AppEntrypoint, sdkCtx sdk.Context, accounts []simtypes.Account, chainID string, ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { groupInfo, acc, account, err := randomGroup(r, k, ak, sdkCtx, accounts, s) if err != nil { @@ -760,7 +759,7 @@ func SimulateMsgUpdateGroupPolicyAdmin( s *SharedState, ) simtypes.Operation { return func( - r *rand.Rand, app *baseapp.BaseApp, sdkCtx sdk.Context, accounts []simtypes.Account, chainID string, + r *rand.Rand, app simtypes.AppEntrypoint, sdkCtx sdk.Context, accounts []simtypes.Account, chainID string, ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { _, groupPolicy, acc, account, err := randomGroupPolicy(r, k, ak, sdkCtx, accounts, s) if err != nil { @@ -834,7 +833,7 @@ func SimulateMsgUpdateGroupPolicyDecisionPolicy( s *SharedState, ) simtypes.Operation { return func( - r *rand.Rand, app *baseapp.BaseApp, sdkCtx sdk.Context, accounts []simtypes.Account, chainID string, + r *rand.Rand, app simtypes.AppEntrypoint, sdkCtx sdk.Context, accounts []simtypes.Account, chainID string, ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { _, groupPolicy, acc, account, err := randomGroupPolicy(r, k, ak, sdkCtx, accounts, s) if err != nil { @@ -908,7 +907,7 @@ func SimulateMsgUpdateGroupPolicyMetadata( s *SharedState, ) simtypes.Operation { return func( - r *rand.Rand, app *baseapp.BaseApp, sdkCtx sdk.Context, accounts []simtypes.Account, chainID string, + r *rand.Rand, app simtypes.AppEntrypoint, sdkCtx sdk.Context, accounts []simtypes.Account, chainID string, ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { _, groupPolicy, acc, account, err := randomGroupPolicy(r, k, ak, sdkCtx, accounts, s) if err != nil { @@ -969,7 +968,7 @@ func SimulateMsgWithdrawProposal( s *SharedState, ) simtypes.Operation { return func( - r *rand.Rand, app *baseapp.BaseApp, sdkCtx sdk.Context, accounts []simtypes.Account, chainID string, + r *rand.Rand, app simtypes.AppEntrypoint, sdkCtx sdk.Context, accounts []simtypes.Account, chainID string, ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { g, groupPolicy, _, _, err := randomGroupPolicy(r, k, ak, sdkCtx, accounts, s) if err != nil { @@ -1085,7 +1084,7 @@ func SimulateMsgVote( s *SharedState, ) simtypes.Operation { return func( - r *rand.Rand, app *baseapp.BaseApp, sdkCtx sdk.Context, accounts []simtypes.Account, chainID string, + r *rand.Rand, app simtypes.AppEntrypoint, sdkCtx sdk.Context, accounts []simtypes.Account, chainID string, ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { g, groupPolicy, _, _, err := randomGroupPolicy(r, k, ak, sdkCtx, accounts, s) if err != nil { @@ -1198,7 +1197,7 @@ func SimulateMsgExec( s *SharedState, ) simtypes.Operation { return func( - r *rand.Rand, app *baseapp.BaseApp, sdkCtx sdk.Context, accounts []simtypes.Account, chainID string, + r *rand.Rand, app simtypes.AppEntrypoint, sdkCtx sdk.Context, accounts []simtypes.Account, chainID string, ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { _, groupPolicy, acc, account, err := randomGroupPolicy(r, k, ak, sdkCtx, accounts, s) if err != nil { @@ -1283,7 +1282,7 @@ func SimulateMsgLeaveGroup( s *SharedState, ) simtypes.Operation { return func( - r *rand.Rand, app *baseapp.BaseApp, sdkCtx sdk.Context, accounts []simtypes.Account, chainID string, + r *rand.Rand, app simtypes.AppEntrypoint, sdkCtx sdk.Context, accounts []simtypes.Account, chainID string, ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { groupInfo, policyInfo, _, _, err := randomGroupPolicy(r, k, ak, sdkCtx, accounts, s) if err != nil { diff --git a/x/mint/simulation/proposals.go b/x/mint/simulation/proposals.go index be6320ac8326..570bf203efcc 100644 --- a/x/mint/simulation/proposals.go +++ b/x/mint/simulation/proposals.go @@ -1,6 +1,7 @@ package simulation import ( + "context" "math/rand" coreaddress "cosmossdk.io/core/address" @@ -23,7 +24,7 @@ const ( // ProposalMsgs defines the module weighted proposals' contents func ProposalMsgs() []simtypes.WeightedProposalMsg { return []simtypes.WeightedProposalMsg{ - simulation.NewWeightedProposalMsg( + simulation.NewWeightedProposalMsgX( OpWeightMsgUpdateParams, DefaultWeightMsgUpdateParams, SimulateMsgUpdateParams, @@ -32,7 +33,7 @@ func ProposalMsgs() []simtypes.WeightedProposalMsg { } // SimulateMsgUpdateParams returns a random MsgUpdateParams -func SimulateMsgUpdateParams(r *rand.Rand, _ []simtypes.Account, ac coreaddress.Codec) (sdk.Msg, error) { +func SimulateMsgUpdateParams(_ context.Context, r *rand.Rand, _ []simtypes.Account, ac coreaddress.Codec) (sdk.Msg, error) { // use the default gov module account address as authority var authority sdk.AccAddress = address.Module("gov") diff --git a/x/mint/simulation/proposals_test.go b/x/mint/simulation/proposals_test.go index 767bbfad1508..abc470a76d81 100644 --- a/x/mint/simulation/proposals_test.go +++ b/x/mint/simulation/proposals_test.go @@ -1,6 +1,7 @@ package simulation_test import ( + "context" "math/rand" "testing" @@ -33,7 +34,7 @@ func TestProposalMsgs(t *testing.T) { assert.Equal(t, simulation.OpWeightMsgUpdateParams, w0.AppParamsKey()) assert.Equal(t, simulation.DefaultWeightMsgUpdateParams, w0.DefaultWeight()) - msg, err := w0.MsgSimulatorFn()(r, accounts, ac) + msg, err := w0.MsgSimulatorFn()(context.Background(), r, accounts, ac) assert.NilError(t, err) msgUpdateParams, ok := msg.(*types.MsgUpdateParams) assert.Assert(t, ok) diff --git a/x/nft/simulation/operations.go b/x/nft/simulation/operations.go index 5128d8147749..f13a47c49e84 100644 --- a/x/nft/simulation/operations.go +++ b/x/nft/simulation/operations.go @@ -6,7 +6,6 @@ import ( "cosmossdk.io/x/nft" "cosmossdk.io/x/nft/keeper" - "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" cdctypes "github.com/cosmos/cosmos-sdk/codec/types" @@ -61,7 +60,7 @@ func SimulateMsgSend( k keeper.Keeper, ) simtypes.Operation { return func( - r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accs []simtypes.Account, chainID string, + r *rand.Rand, app simtypes.AppEntrypoint, ctx sdk.Context, accs []simtypes.Account, chainID string, ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { sender, _ := simtypes.RandomAcc(r, accs) receiver, _ := simtypes.RandomAcc(r, accs) diff --git a/x/protocolpool/simulation/operations.go b/x/protocolpool/simulation/operations.go index 004b850d52be..01da9484f953 100644 --- a/x/protocolpool/simulation/operations.go +++ b/x/protocolpool/simulation/operations.go @@ -6,7 +6,6 @@ import ( "cosmossdk.io/x/protocolpool/keeper" "cosmossdk.io/x/protocolpool/types" - "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" @@ -47,7 +46,7 @@ func WeightedOperations( // a random account sends a random amount of its funds to the community pool. func SimulateMsgFundCommunityPool(txConfig client.TxConfig, ak types.AccountKeeper, bk types.BankKeeper, k keeper.Keeper) simtypes.Operation { return func( - r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accs []simtypes.Account, chainID string, + r *rand.Rand, app simtypes.AppEntrypoint, ctx sdk.Context, accs []simtypes.Account, chainID string, ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { funder, _ := simtypes.RandomAcc(r, accs) diff --git a/x/protocolpool/simulation/proposals.go b/x/protocolpool/simulation/proposals.go index 9a1af074a53b..0afddda38f01 100644 --- a/x/protocolpool/simulation/proposals.go +++ b/x/protocolpool/simulation/proposals.go @@ -1,6 +1,7 @@ package simulation import ( + "context" "math/rand" coreaddress "cosmossdk.io/core/address" @@ -20,7 +21,7 @@ const ( func ProposalMsgs() []simtypes.WeightedProposalMsg { return []simtypes.WeightedProposalMsg{ - simulation.NewWeightedProposalMsg( + simulation.NewWeightedProposalMsgX( OpWeightMsgCommunityPoolSpend, DefaultWeightMsgCommunityPoolSpend, SimulateMsgCommunityPoolSpend, @@ -28,7 +29,7 @@ func ProposalMsgs() []simtypes.WeightedProposalMsg { } } -func SimulateMsgCommunityPoolSpend(r *rand.Rand, _ []simtypes.Account, cdc coreaddress.Codec) (sdk.Msg, error) { +func SimulateMsgCommunityPoolSpend(_ context.Context, r *rand.Rand, _ []simtypes.Account, cdc coreaddress.Codec) (sdk.Msg, error) { // use the default gov module account address as authority var authority sdk.AccAddress = address.Module("gov") diff --git a/x/protocolpool/simulation/proposals_test.go b/x/protocolpool/simulation/proposals_test.go index 96046c2589f9..b452b01970fc 100644 --- a/x/protocolpool/simulation/proposals_test.go +++ b/x/protocolpool/simulation/proposals_test.go @@ -1,6 +1,7 @@ package simulation_test import ( + "context" "math/rand" "testing" @@ -32,7 +33,7 @@ func TestProposalMsgs(t *testing.T) { assert.Equal(t, simulation.OpWeightMsgCommunityPoolSpend, w0.AppParamsKey()) assert.Equal(t, simulation.DefaultWeightMsgCommunityPoolSpend, w0.DefaultWeight()) - msg, err := w0.MsgSimulatorFn()(r, accounts, addressCodec) + msg, err := w0.MsgSimulatorFn()(context.Background(), r, accounts, addressCodec) assert.NilError(t, err) msgCommunityPoolSpend, ok := msg.(*pooltypes.MsgCommunityPoolSpend) assert.Assert(t, ok) diff --git a/x/simulation/params.go b/x/simulation/params.go index da62ffe1e87a..4fce44cff82e 100644 --- a/x/simulation/params.go +++ b/x/simulation/params.go @@ -1,15 +1,18 @@ package simulation import ( + "context" "encoding/json" "math/rand" cmtproto "github.com/cometbft/cometbft/api/cometbft/types/v1" "github.com/cometbft/cometbft/types" + "cosmossdk.io/core/address" stakingtypes "cosmossdk.io/x/staking/types" "github.com/cosmos/cosmos-sdk/codec" + sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/simulation" ) @@ -125,13 +128,20 @@ func NewSimLegacyParamChange(subspace, key string, simVal simulation.SimValFn) s // WeightedProposalMsg defines a common struct for proposal msgs defined by external modules (i.e outside gov) type WeightedProposalMsg struct { - appParamsKey string // key used to retrieve the value of the weight from the simulation application params - defaultWeight int // default weight - msgSimulatorFn simulation.MsgSimulatorFn // msg simulator function + appParamsKey string // key used to retrieve the value of the weight from the simulation application params + defaultWeight int // default weight + msgSimulatorFnX simulation.MsgSimulatorFnX // msg simulator function } +// Deprecated: use NewWeightedProposalMsgX instead func NewWeightedProposalMsg(appParamsKey string, defaultWeight int, msgSimulatorFn simulation.MsgSimulatorFn) simulation.WeightedProposalMsg { - return &WeightedProposalMsg{appParamsKey: appParamsKey, defaultWeight: defaultWeight, msgSimulatorFn: msgSimulatorFn} + return NewWeightedProposalMsgX(appParamsKey, defaultWeight, func(_ context.Context, r *rand.Rand, accs []simulation.Account, cdc address.Codec) (sdk.Msg, error) { + return msgSimulatorFn(r, accs, cdc) + }) +} + +func NewWeightedProposalMsgX(appParamsKey string, defaultWeight int, msgSimulatorFn simulation.MsgSimulatorFnX) simulation.WeightedProposalMsg { + return &WeightedProposalMsg{appParamsKey: appParamsKey, defaultWeight: defaultWeight, msgSimulatorFnX: msgSimulatorFn} } func (w WeightedProposalMsg) AppParamsKey() string { @@ -142,8 +152,8 @@ func (w WeightedProposalMsg) DefaultWeight() int { return w.defaultWeight } -func (w WeightedProposalMsg) MsgSimulatorFn() simulation.MsgSimulatorFn { - return w.msgSimulatorFn +func (w WeightedProposalMsg) MsgSimulatorFn() simulation.MsgSimulatorFnX { + return w.msgSimulatorFnX } // Legacy Proposal Content diff --git a/x/simulation/util.go b/x/simulation/util.go index 5fba0973f850..c2a3cdcd7bad 100644 --- a/x/simulation/util.go +++ b/x/simulation/util.go @@ -6,7 +6,6 @@ import ( "math/rand" "testing" - "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims" @@ -65,7 +64,7 @@ func mustMarshalJSONIndent(o interface{}) []byte { // OperationInput is a struct that holds all the needed values to generate a tx and deliver it type OperationInput struct { R *rand.Rand - App *baseapp.BaseApp + App simtypes.AppEntrypoint TxGen client.TxConfig Cdc *codec.ProtoCodec Msg sdk.Msg diff --git a/x/slashing/simulation/operations.go b/x/slashing/simulation/operations.go index 45f61af3a999..e14cef141346 100644 --- a/x/slashing/simulation/operations.go +++ b/x/slashing/simulation/operations.go @@ -7,7 +7,6 @@ import ( "cosmossdk.io/x/slashing/keeper" "cosmossdk.io/x/slashing/types" - "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" codectypes "github.com/cosmos/cosmos-sdk/codec/types" @@ -59,7 +58,7 @@ func SimulateMsgUnjail( sk types.StakingKeeper, ) simtypes.Operation { return func( - r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, + r *rand.Rand, app simtypes.AppEntrypoint, ctx sdk.Context, accs []simtypes.Account, chainID string, ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { msgType := sdk.MsgTypeURL(&types.MsgUnjail{}) diff --git a/x/slashing/simulation/proposals.go b/x/slashing/simulation/proposals.go index 1ea39d97f19a..d625360de80f 100644 --- a/x/slashing/simulation/proposals.go +++ b/x/slashing/simulation/proposals.go @@ -1,6 +1,7 @@ package simulation import ( + "context" "math/rand" "time" @@ -24,7 +25,7 @@ const ( // ProposalMsgs defines the module weighted proposals' contents func ProposalMsgs() []simtypes.WeightedProposalMsg { return []simtypes.WeightedProposalMsg{ - simulation.NewWeightedProposalMsg( + simulation.NewWeightedProposalMsgX( OpWeightMsgUpdateParams, DefaultWeightMsgUpdateParams, SimulateMsgUpdateParams, @@ -33,7 +34,7 @@ func ProposalMsgs() []simtypes.WeightedProposalMsg { } // SimulateMsgUpdateParams returns a random MsgUpdateParams -func SimulateMsgUpdateParams(r *rand.Rand, _ []simtypes.Account, ac coreaddress.Codec) (sdk.Msg, error) { +func SimulateMsgUpdateParams(_ context.Context, r *rand.Rand, _ []simtypes.Account, ac coreaddress.Codec) (sdk.Msg, error) { // use the default gov module account address as authority var authority sdk.AccAddress = address.Module("gov") diff --git a/x/slashing/simulation/proposals_test.go b/x/slashing/simulation/proposals_test.go index d2b553964a00..f741f9ff689b 100644 --- a/x/slashing/simulation/proposals_test.go +++ b/x/slashing/simulation/proposals_test.go @@ -1,6 +1,7 @@ package simulation_test import ( + "context" "math/rand" "testing" "time" @@ -34,7 +35,7 @@ func TestProposalMsgs(t *testing.T) { assert.Equal(t, simulation.OpWeightMsgUpdateParams, w0.AppParamsKey()) assert.Equal(t, simulation.DefaultWeightMsgUpdateParams, w0.DefaultWeight()) - msg, err := w0.MsgSimulatorFn()(r, accounts, ac) + msg, err := w0.MsgSimulatorFn()(context.Background(), r, accounts, ac) assert.NilError(t, err) msgUpdateParams, ok := msg.(*types.MsgUpdateParams) assert.Assert(t, ok) diff --git a/x/staking/simulation/operations.go b/x/staking/simulation/operations.go index 7b3eecbbb6db..83ca16fb43c6 100644 --- a/x/staking/simulation/operations.go +++ b/x/staking/simulation/operations.go @@ -9,7 +9,6 @@ import ( "cosmossdk.io/x/staking/keeper" "cosmossdk.io/x/staking/types" - "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/testutil" @@ -124,7 +123,7 @@ func SimulateMsgCreateValidator( k *keeper.Keeper, ) simtypes.Operation { return func( - r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accs []simtypes.Account, chainID string, + r *rand.Rand, app simtypes.AppEntrypoint, ctx sdk.Context, accs []simtypes.Account, chainID string, ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { msgType := sdk.MsgTypeURL(&types.MsgCreateValidator{}) @@ -233,7 +232,7 @@ func SimulateMsgEditValidator( k *keeper.Keeper, ) simtypes.Operation { return func( - r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accs []simtypes.Account, chainID string, + r *rand.Rand, app simtypes.AppEntrypoint, ctx sdk.Context, accs []simtypes.Account, chainID string, ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { msgType := sdk.MsgTypeURL(&types.MsgEditValidator{}) @@ -308,7 +307,7 @@ func SimulateMsgDelegate( k *keeper.Keeper, ) simtypes.Operation { return func( - r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accs []simtypes.Account, chainID string, + r *rand.Rand, app simtypes.AppEntrypoint, ctx sdk.Context, accs []simtypes.Account, chainID string, ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { msgType := sdk.MsgTypeURL(&types.MsgDelegate{}) denom, err := k.BondDenom(ctx) @@ -390,7 +389,7 @@ func SimulateMsgUndelegate( k *keeper.Keeper, ) simtypes.Operation { return func( - r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accs []simtypes.Account, chainID string, + r *rand.Rand, app simtypes.AppEntrypoint, ctx sdk.Context, accs []simtypes.Account, chainID string, ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { msgType := sdk.MsgTypeURL(&types.MsgUndelegate{}) @@ -509,7 +508,7 @@ func SimulateMsgCancelUnbondingDelegate( k *keeper.Keeper, ) simtypes.Operation { return func( - r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accs []simtypes.Account, chainID string, + r *rand.Rand, app simtypes.AppEntrypoint, ctx sdk.Context, accs []simtypes.Account, chainID string, ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { msgType := sdk.MsgTypeURL(&types.MsgCancelUnbondingDelegation{}) @@ -613,7 +612,7 @@ func SimulateMsgBeginRedelegate( k *keeper.Keeper, ) simtypes.Operation { return func( - r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accs []simtypes.Account, chainID string, + r *rand.Rand, app simtypes.AppEntrypoint, ctx sdk.Context, accs []simtypes.Account, chainID string, ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { msgType := sdk.MsgTypeURL(&types.MsgBeginRedelegate{}) @@ -757,7 +756,7 @@ func SimulateMsgBeginRedelegate( func SimulateMsgRotateConsPubKey(txGen client.TxConfig, ak types.AccountKeeper, bk types.BankKeeper, k *keeper.Keeper) simtypes.Operation { return func( - r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accs []simtypes.Account, chainID string, + r *rand.Rand, app simtypes.AppEntrypoint, ctx sdk.Context, accs []simtypes.Account, chainID string, ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { msgType := sdk.MsgTypeURL(&types.MsgRotateConsPubKey{}) diff --git a/x/staking/simulation/proposals.go b/x/staking/simulation/proposals.go index 000984b46cdd..36afe6db90d3 100644 --- a/x/staking/simulation/proposals.go +++ b/x/staking/simulation/proposals.go @@ -1,11 +1,11 @@ package simulation import ( + "context" "math/rand" "time" coreaddress "cosmossdk.io/core/address" - sdkmath "cosmossdk.io/math" "cosmossdk.io/x/staking/types" sdk "github.com/cosmos/cosmos-sdk/types" @@ -24,7 +24,7 @@ const ( // ProposalMsgs defines the module weighted proposals' contents func ProposalMsgs() []simtypes.WeightedProposalMsg { return []simtypes.WeightedProposalMsg{ - simulation.NewWeightedProposalMsg( + simulation.NewWeightedProposalMsgX( OpWeightMsgUpdateParams, DefaultWeightMsgUpdateParams, SimulateMsgUpdateParams, @@ -33,17 +33,16 @@ func ProposalMsgs() []simtypes.WeightedProposalMsg { } // SimulateMsgUpdateParams returns a random MsgUpdateParams -func SimulateMsgUpdateParams(r *rand.Rand, _ []simtypes.Account, addressCodec coreaddress.Codec) (sdk.Msg, error) { +func SimulateMsgUpdateParams(_ context.Context, r *rand.Rand, _ []simtypes.Account, addressCodec coreaddress.Codec) (sdk.Msg, error) { // use the default gov module account address as authority var authority sdk.AccAddress = address.Module("gov") params := types.DefaultParams() - params.BondDenom = simtypes.RandStringOfLength(r, 10) params.HistoricalEntries = uint32(simtypes.RandIntBetween(r, 0, 1000)) params.MaxEntries = uint32(simtypes.RandIntBetween(r, 1, 1000)) params.MaxValidators = uint32(simtypes.RandIntBetween(r, 1, 1000)) params.UnbondingTime = time.Duration(simtypes.RandTimestamp(r).UnixNano()) - params.MinCommissionRate = simtypes.RandomDecAmount(r, sdkmath.LegacyNewDec(1)) + // changes to MinCommissionRate or BondDenom create issues for in flight messages or state operations addr, err := addressCodec.BytesToString(authority) if err != nil { diff --git a/x/staking/simulation/proposals_test.go b/x/staking/simulation/proposals_test.go index 64eb447a8559..4373ae15b290 100644 --- a/x/staking/simulation/proposals_test.go +++ b/x/staking/simulation/proposals_test.go @@ -1,13 +1,12 @@ package simulation_test import ( + "context" "math/rand" "testing" - "time" "gotest.tools/v3/assert" - sdkmath "cosmossdk.io/math" "cosmossdk.io/x/staking/simulation" "cosmossdk.io/x/staking/types" @@ -33,7 +32,7 @@ func TestProposalMsgs(t *testing.T) { assert.Equal(t, simulation.OpWeightMsgUpdateParams, w0.AppParamsKey()) assert.Equal(t, simulation.DefaultWeightMsgUpdateParams, w0.DefaultWeight()) - msg, err := w0.MsgSimulatorFn()(r, accounts, addressCodec) + msg, err := w0.MsgSimulatorFn()(context.Background(), r, accounts, addressCodec) assert.NilError(t, err) msgUpdateParams, ok := msg.(*types.MsgUpdateParams) assert.Assert(t, ok) @@ -42,10 +41,9 @@ func TestProposalMsgs(t *testing.T) { assert.NilError(t, err) assert.Equal(t, addr, msgUpdateParams.Authority) - assert.Equal(t, "GqiQWIXnku", msgUpdateParams.Params.BondDenom) - assert.Equal(t, uint32(213), msgUpdateParams.Params.MaxEntries) - assert.Equal(t, uint32(300), msgUpdateParams.Params.HistoricalEntries) - assert.Equal(t, uint32(539), msgUpdateParams.Params.MaxValidators) - assert.Equal(t, 8898194435*time.Second, msgUpdateParams.Params.UnbondingTime) - assert.DeepEqual(t, sdkmath.LegacyNewDecWithPrec(579040435581502128, 18), msgUpdateParams.Params.MinCommissionRate) + assert.Equal(t, "stake", msgUpdateParams.Params.BondDenom) + assert.Equal(t, uint32(905), msgUpdateParams.Params.MaxEntries) + assert.Equal(t, uint32(540), msgUpdateParams.Params.HistoricalEntries) + assert.Equal(t, uint32(151), msgUpdateParams.Params.MaxValidators) + assert.Equal(t, "2417694h42m25s", msgUpdateParams.Params.UnbondingTime.String()) } From 339e26ea8f3a1f2c81ae2fa8064a73f24dd96883 Mon Sep 17 00:00:00 2001 From: Aaron Craelius Date: Wed, 24 Jul 2024 15:42:47 +0200 Subject: [PATCH 41/50] feat(schema)!: add more range methods, rename EnumDefinition -> EnumType (#21043) --- schema/enum.go | 15 +++-- schema/enum_test.go | 14 ++-- schema/field.go | 12 ++-- schema/field_test.go | 24 +++---- schema/kind.go | 2 +- schema/module_schema.go | 26 +++++++- schema/module_schema_test.go | 126 +++++++++++++++++++++++++---------- schema/object_type.go | 5 ++ schema/object_type_test.go | 4 +- schema/type.go | 5 +- 10 files changed, 163 insertions(+), 70 deletions(-) diff --git a/schema/enum.go b/schema/enum.go index 5afb0ecbd0b8..5ceb435313d1 100644 --- a/schema/enum.go +++ b/schema/enum.go @@ -5,8 +5,8 @@ import ( "fmt" ) -// EnumDefinition represents the definition of an enum type. -type EnumDefinition struct { +// EnumType represents the definition of an enum type. +type EnumType struct { // Name is the name of the enum type. It must conform to the NameFormat regular expression. // Its name must be unique between all enum types and object types in the module. // The same enum, however, can be used in multiple object types and fields as long as the @@ -18,10 +18,15 @@ type EnumDefinition struct { Values []string } -func (EnumDefinition) isType() {} +// TypeName implements the Type interface. +func (e EnumType) TypeName() string { + return e.Name +} + +func (EnumType) isType() {} // Validate validates the enum definition. -func (e EnumDefinition) Validate() error { +func (e EnumType) Validate() error { if !ValidateName(e.Name) { return fmt.Errorf("invalid enum definition name %q", e.Name) } @@ -44,7 +49,7 @@ func (e EnumDefinition) Validate() error { } // ValidateValue validates that the value is a valid enum value. -func (e EnumDefinition) ValidateValue(value string) error { +func (e EnumType) ValidateValue(value string) error { for _, v := range e.Values { if v == value { return nil diff --git a/schema/enum_test.go b/schema/enum_test.go index 435449d0c564..51881f29ff09 100644 --- a/schema/enum_test.go +++ b/schema/enum_test.go @@ -8,12 +8,12 @@ import ( func TestEnumDefinition_Validate(t *testing.T) { tests := []struct { name string - enum EnumDefinition + enum EnumType errContains string }{ { name: "valid enum", - enum: EnumDefinition{ + enum: EnumType{ Name: "test", Values: []string{"a", "b", "c"}, }, @@ -21,7 +21,7 @@ func TestEnumDefinition_Validate(t *testing.T) { }, { name: "empty name", - enum: EnumDefinition{ + enum: EnumType{ Name: "", Values: []string{"a", "b", "c"}, }, @@ -29,7 +29,7 @@ func TestEnumDefinition_Validate(t *testing.T) { }, { name: "empty values", - enum: EnumDefinition{ + enum: EnumType{ Name: "test", Values: []string{}, }, @@ -37,7 +37,7 @@ func TestEnumDefinition_Validate(t *testing.T) { }, { name: "empty value", - enum: EnumDefinition{ + enum: EnumType{ Name: "test", Values: []string{"a", "", "c"}, }, @@ -45,7 +45,7 @@ func TestEnumDefinition_Validate(t *testing.T) { }, { name: "duplicate value", - enum: EnumDefinition{ + enum: EnumType{ Name: "test", Values: []string{"a", "b", "a"}, }, @@ -72,7 +72,7 @@ func TestEnumDefinition_Validate(t *testing.T) { } func TestEnumDefinition_ValidateValue(t *testing.T) { - enum := EnumDefinition{ + enum := EnumType{ Name: "test", Values: []string{"a", "b", "c"}, } diff --git a/schema/field.go b/schema/field.go index a11cc756683f..bd3e3997e1ed 100644 --- a/schema/field.go +++ b/schema/field.go @@ -13,11 +13,11 @@ type Field struct { // Nullable indicates whether null values are accepted for the field. Key fields CANNOT be nullable. Nullable bool - // EnumDefinition is the definition of the enum type and is only valid when Kind is EnumKind. + // EnumType is the definition of the enum type and is only valid when Kind is EnumKind. // The same enum types can be reused in the same module schema, but they always must contain // the same values for the same enum name. This possibly introduces some duplication of // definitions but makes it easier to reason about correctness and validation in isolation. - EnumDefinition EnumDefinition + EnumType EnumType } // Validate validates the field. @@ -34,10 +34,10 @@ func (c Field) Validate() error { // enum definition only valid with EnumKind if c.Kind == EnumKind { - if err := c.EnumDefinition.Validate(); err != nil { + if err := c.EnumType.Validate(); err != nil { return fmt.Errorf("invalid enum definition for field %q: %v", c.Name, err) //nolint:errorlint // false positive due to using go1.12 } - } else if c.Kind != EnumKind && (c.EnumDefinition.Name != "" || c.EnumDefinition.Values != nil) { + } else if c.Kind != EnumKind && (c.EnumType.Name != "" || c.EnumType.Values != nil) { return fmt.Errorf("enum definition is only valid for field %q with type EnumKind", c.Name) } @@ -45,7 +45,7 @@ func (c Field) Validate() error { } // ValidateValue validates that the value conforms to the field's kind and nullability. -// Unlike Kind.ValidateValue, it also checks that the value conforms to the EnumDefinition +// Unlike Kind.ValidateValue, it also checks that the value conforms to the EnumType // if the field is an EnumKind. func (c Field) ValidateValue(value interface{}) error { if value == nil { @@ -60,7 +60,7 @@ func (c Field) ValidateValue(value interface{}) error { } if c.Kind == EnumKind { - return c.EnumDefinition.ValidateValue(value.(string)) + return c.EnumType.ValidateValue(value.(string)) } return nil diff --git a/schema/field_test.go b/schema/field_test.go index ea839ece08cb..5fd7d8015c73 100644 --- a/schema/field_test.go +++ b/schema/field_test.go @@ -46,18 +46,18 @@ func TestField_Validate(t *testing.T) { { name: "enum definition with non-EnumKind", field: Field{ - Name: "field1", - Kind: StringKind, - EnumDefinition: EnumDefinition{Name: "enum"}, + Name: "field1", + Kind: StringKind, + EnumType: EnumType{Name: "enum"}, }, errContains: "enum definition is only valid for field \"field1\" with type EnumKind", }, { name: "valid enum", field: Field{ - Name: "field1", - Kind: EnumKind, - EnumDefinition: EnumDefinition{Name: "enum", Values: []string{"a", "b"}}, + Name: "field1", + Kind: EnumKind, + EnumType: EnumType{Name: "enum", Values: []string{"a", "b"}}, }, }, } @@ -128,9 +128,9 @@ func TestField_ValidateValue(t *testing.T) { { name: "valid enum", field: Field{ - Name: "field1", - Kind: EnumKind, - EnumDefinition: EnumDefinition{Name: "enum", Values: []string{"a", "b"}}, + Name: "field1", + Kind: EnumKind, + EnumType: EnumType{Name: "enum", Values: []string{"a", "b"}}, }, value: "a", errContains: "", @@ -138,9 +138,9 @@ func TestField_ValidateValue(t *testing.T) { { name: "invalid enum", field: Field{ - Name: "field1", - Kind: EnumKind, - EnumDefinition: EnumDefinition{Name: "enum", Values: []string{"a", "b"}}, + Name: "field1", + Kind: EnumKind, + EnumType: EnumType{Name: "enum", Values: []string{"a", "b"}}, }, value: "c", errContains: "not a valid enum value", diff --git a/schema/kind.go b/schema/kind.go index c28ce34af046..1cdffc7b7101 100644 --- a/schema/kind.go +++ b/schema/kind.go @@ -78,7 +78,7 @@ const ( AddressKind // EnumKind is an enum type and values of this type must be of the go type string. - // Fields of this type are expected to set the EnumDefinition field in the field definition to the enum + // Fields of this type are expected to set the EnumType field in the field definition to the enum // definition. EnumKind diff --git a/schema/module_schema.go b/schema/module_schema.go index b98744ea8142..f90a44c192b1 100644 --- a/schema/module_schema.go +++ b/schema/module_schema.go @@ -31,7 +31,7 @@ func NewModuleSchema(objectTypes []ObjectType) (ModuleSchema, error) { } func addEnumType(types map[string]Type, field Field) error { - enumDef := field.EnumDefinition + enumDef := field.EnumType if enumDef.Name == "" { return nil } @@ -42,7 +42,7 @@ func addEnumType(types map[string]Type, field Field) error { return nil } - existingEnum, ok := existing.(EnumDefinition) + existingEnum, ok := existing.(EnumType) if !ok { return fmt.Errorf("enum %q already exists as a different non-enum type", enumDef.Name) } @@ -119,3 +119,25 @@ func (s ModuleSchema) Types(f func(Type) bool) { } } } + +// ObjectTypes iterators over all the object types in the schema in alphabetical order. +func (s ModuleSchema) ObjectTypes(f func(ObjectType) bool) { + s.Types(func(t Type) bool { + objTyp, ok := t.(ObjectType) + if ok { + return f(objTyp) + } + return true + }) +} + +// EnumTypes iterators over all the enum types in the schema in alphabetical order. +func (s ModuleSchema) EnumTypes(f func(EnumType) bool) { + s.Types(func(t Type) bool { + enumType, ok := t.(EnumType) + if ok { + return f(enumType) + } + return true + }) +} diff --git a/schema/module_schema_test.go b/schema/module_schema_test.go index 189c7f3b9947..ebd44e653632 100644 --- a/schema/module_schema_test.go +++ b/schema/module_schema_test.go @@ -51,7 +51,7 @@ func TestModuleSchema_Validate(t *testing.T) { { Name: "k", Kind: EnumKind, - EnumDefinition: EnumDefinition{ + EnumType: EnumType{ Name: "enum1", Values: []string{"a", "b"}, }, @@ -61,7 +61,7 @@ func TestModuleSchema_Validate(t *testing.T) { { Name: "v", Kind: EnumKind, - EnumDefinition: EnumDefinition{ + EnumType: EnumType{ Name: "enum1", Values: []string{"a", "b", "c"}, }, @@ -80,7 +80,7 @@ func TestModuleSchema_Validate(t *testing.T) { { Name: "k", Kind: EnumKind, - EnumDefinition: EnumDefinition{ + EnumType: EnumType{ Name: "enum1", Values: []string{"a", "b"}, }, @@ -93,7 +93,7 @@ func TestModuleSchema_Validate(t *testing.T) { { Name: "k", Kind: EnumKind, - EnumDefinition: EnumDefinition{ + EnumType: EnumType{ Name: "enum1", Values: []string{"a", "c"}, }, @@ -111,7 +111,7 @@ func TestModuleSchema_Validate(t *testing.T) { { Name: "k", Kind: EnumKind, - EnumDefinition: EnumDefinition{ + EnumType: EnumType{ Name: "enum1", Values: []string{"a", "b"}, }, @@ -124,7 +124,7 @@ func TestModuleSchema_Validate(t *testing.T) { { Name: "k", Kind: EnumKind, - EnumDefinition: EnumDefinition{ + EnumType: EnumType{ Name: "enum1", Values: []string{"a", "b"}, }, @@ -141,7 +141,7 @@ func TestModuleSchema_Validate(t *testing.T) { { Name: "field1", Kind: EnumKind, - EnumDefinition: EnumDefinition{ + EnumType: EnumType{ Name: "type1", Values: []string{"a", "b"}, }, @@ -179,7 +179,7 @@ func TestModuleSchema_ValidateObjectUpdate(t *testing.T) { }{ { name: "valid object update", - moduleSchema: RequireNewModuleSchema(t, []ObjectType{ + moduleSchema: requireModuleSchema(t, []ObjectType{ { Name: "object1", KeyFields: []Field{ @@ -199,7 +199,7 @@ func TestModuleSchema_ValidateObjectUpdate(t *testing.T) { }, { name: "object type not found", - moduleSchema: RequireNewModuleSchema(t, []ObjectType{ + moduleSchema: requireModuleSchema(t, []ObjectType{ { Name: "object1", KeyFields: []Field{ @@ -219,14 +219,14 @@ func TestModuleSchema_ValidateObjectUpdate(t *testing.T) { }, { name: "type name refers to an enum", - moduleSchema: RequireNewModuleSchema(t, []ObjectType{ + moduleSchema: requireModuleSchema(t, []ObjectType{ { Name: "obj1", KeyFields: []Field{ { Name: "field1", Kind: EnumKind, - EnumDefinition: EnumDefinition{ + EnumType: EnumType{ Name: "enum1", Values: []string{"a", "b"}, }, @@ -258,7 +258,7 @@ func TestModuleSchema_ValidateObjectUpdate(t *testing.T) { } } -func RequireNewModuleSchema(t *testing.T, objectTypes []ObjectType) ModuleSchema { +func requireModuleSchema(t *testing.T, objectTypes []ObjectType) ModuleSchema { t.Helper() moduleSchema, err := NewModuleSchema(objectTypes) if err != nil { @@ -268,7 +268,7 @@ func RequireNewModuleSchema(t *testing.T, objectTypes []ObjectType) ModuleSchema } func TestModuleSchema_LookupType(t *testing.T) { - moduleSchema := RequireNewModuleSchema(t, []ObjectType{ + moduleSchema := requireModuleSchema(t, []ObjectType{ { Name: "object1", KeyFields: []Field{ @@ -295,14 +295,18 @@ func TestModuleSchema_LookupType(t *testing.T) { } } -func TestModuleSchema_ScanTypes(t *testing.T) { - moduleSchema := RequireNewModuleSchema(t, []ObjectType{ +func exampleSchema(t *testing.T) ModuleSchema { + return requireModuleSchema(t, []ObjectType{ { Name: "object1", KeyFields: []Field{ { Name: "field1", - Kind: StringKind, + Kind: EnumKind, + EnumType: EnumType{ + Name: "enum2", + Values: []string{"d", "e", "f"}, + }, }, }, }, @@ -311,40 +315,94 @@ func TestModuleSchema_ScanTypes(t *testing.T) { KeyFields: []Field{ { Name: "field1", - Kind: StringKind, + Kind: EnumKind, + EnumType: EnumType{ + Name: "enum1", + Values: []string{"a", "b", "c"}, + }, }, }, }, }) +} - var objectTypeNames []string +func TestModuleSchema_Types(t *testing.T) { + moduleSchema := exampleSchema(t) + + var typeNames []string moduleSchema.Types(func(typ Type) bool { - objectType, ok := typ.(ObjectType) - if !ok { - t.Fatalf("expected object type, got %T", typ) - } - objectTypeNames = append(objectTypeNames, objectType.Name) + typeNames = append(typeNames, typ.TypeName()) return true }) - expected := []string{"object1", "object2"} - if !reflect.DeepEqual(objectTypeNames, expected) { - t.Fatalf("expected object type names %v, got %v", expected, objectTypeNames) + expected := []string{"enum1", "enum2", "object1", "object2"} + if !reflect.DeepEqual(typeNames, expected) { + t.Fatalf("expected %v, got %v", expected, typeNames) } - objectTypeNames = nil + typeNames = nil // scan just the first type and return false moduleSchema.Types(func(typ Type) bool { - objectType, ok := typ.(ObjectType) - if !ok { - t.Fatalf("expected object type, got %T", typ) - } - objectTypeNames = append(objectTypeNames, objectType.Name) + typeNames = append(typeNames, typ.TypeName()) + return false + }) + + expected = []string{"enum1"} + if !reflect.DeepEqual(typeNames, expected) { + t.Fatalf("expected %v, got %v", expected, typeNames) + } +} + +func TestModuleSchema_ObjectTypes(t *testing.T) { + moduleSchema := exampleSchema(t) + + var typeNames []string + moduleSchema.ObjectTypes(func(typ ObjectType) bool { + typeNames = append(typeNames, typ.Name) + return true + }) + + expected := []string{"object1", "object2"} + if !reflect.DeepEqual(typeNames, expected) { + t.Fatalf("expected %v, got %v", expected, typeNames) + } + + typeNames = nil + // scan just the first type and return false + moduleSchema.ObjectTypes(func(typ ObjectType) bool { + typeNames = append(typeNames, typ.Name) return false }) expected = []string{"object1"} - if !reflect.DeepEqual(objectTypeNames, expected) { - t.Fatalf("expected object type names %v, got %v", expected, objectTypeNames) + if !reflect.DeepEqual(typeNames, expected) { + t.Fatalf("expected %v, got %v", expected, typeNames) + } +} + +func TestModuleSchema_EnumTypes(t *testing.T) { + moduleSchema := exampleSchema(t) + + var typeNames []string + moduleSchema.EnumTypes(func(typ EnumType) bool { + typeNames = append(typeNames, typ.Name) + return true + }) + + expected := []string{"enum1", "enum2"} + if !reflect.DeepEqual(typeNames, expected) { + t.Fatalf("expected %v, got %v", expected, typeNames) + } + + typeNames = nil + // scan just the first type and return false + moduleSchema.EnumTypes(func(typ EnumType) bool { + typeNames = append(typeNames, typ.Name) + return false + }) + + expected = []string{"enum1"} + if !reflect.DeepEqual(typeNames, expected) { + t.Fatalf("expected %v, got %v", expected, typeNames) } } diff --git a/schema/object_type.go b/schema/object_type.go index 9dd3742a55d5..379d7d4a8382 100644 --- a/schema/object_type.go +++ b/schema/object_type.go @@ -27,6 +27,11 @@ type ObjectType struct { RetainDeletions bool } +// TypeName implements the Type interface. +func (o ObjectType) TypeName() string { + return o.Name +} + func (ObjectType) isType() {} // Validate validates the object type. diff --git a/schema/object_type_test.go b/schema/object_type_test.go index 0a78a371aa96..68a85111b7b6 100644 --- a/schema/object_type_test.go +++ b/schema/object_type_test.go @@ -170,7 +170,7 @@ func TestObjectType_Validate(t *testing.T) { { Name: "key", Kind: EnumKind, - EnumDefinition: EnumDefinition{ + EnumType: EnumType{ Name: "enum1", Values: []string{"a", "b"}, }, @@ -180,7 +180,7 @@ func TestObjectType_Validate(t *testing.T) { { Name: "value", Kind: EnumKind, - EnumDefinition: EnumDefinition{ + EnumType: EnumType{ Name: "enum1", Values: []string{"c", "b"}, }, diff --git a/schema/type.go b/schema/type.go index 1b3ef0657734..75155de8688f 100644 --- a/schema/type.go +++ b/schema/type.go @@ -1,7 +1,10 @@ package schema // Type is an interface that all types in the schema implement. -// Currently these are ObjectType and EnumDefinition. +// Currently these are ObjectType and EnumType. type Type interface { + // TypeName returns the type's name. + TypeName() string + isType() } From 0fda53f265de4bcf4be1a13ea9fad450fc2e66d4 Mon Sep 17 00:00:00 2001 From: Facundo Medica <14063057+facundomedica@users.noreply.github.com> Date: Wed, 24 Jul 2024 17:07:50 +0200 Subject: [PATCH 42/50] feat(x/protocolpool,x/distribution)!: remove dependency + fix continuous fund bug (#20790) --- api/cosmos/protocolpool/v1/genesis.pulsar.go | 1013 ++++++++++++++--- simapp/app.go | 67 +- simapp/app_config.go | 2 + simapp/v2/app_config.go | 2 + .../distribution/keeper/msg_server_test.go | 15 +- tests/integration/gov/keeper/keeper_test.go | 13 +- tests/integration/protocolpool/module_test.go | 5 +- testutil/configurator/configurator.go | 2 + x/distribution/CHANGELOG.md | 8 +- x/distribution/depinject.go | 4 +- x/distribution/go.mod | 1 + x/distribution/go.sum | 2 - x/distribution/keeper/allocation.go | 9 +- x/distribution/keeper/allocation_test.go | 12 +- x/distribution/keeper/delegation_test.go | 18 - x/distribution/keeper/grpc_query.go | 11 +- x/distribution/keeper/grpc_query_test.go | 7 +- x/distribution/keeper/keeper.go | 3 - x/distribution/keeper/keeper_test.go | 5 +- x/distribution/keeper/migrations.go | 2 +- x/distribution/keeper/msg_server.go | 4 +- x/distribution/keeper/msg_server_test.go | 6 +- .../migrations/v4/migrate_funds_test.go | 2 - x/distribution/module.go | 4 +- .../testutil/expected_keepers_mocks.go | 80 -- x/distribution/types/expected_keepers.go | 8 - x/distribution/types/keys.go | 7 +- x/gov/testutil/expected_keepers.go | 2 +- x/gov/testutil/expected_keepers_mocks.go | 2 +- x/gov/types/expected_keepers.go | 2 +- x/protocolpool/CHANGELOG.md | 30 + x/protocolpool/keeper/genesis.go | 33 +- x/protocolpool/keeper/genesis_test.go | 11 + x/protocolpool/keeper/keeper.go | 254 +++-- x/protocolpool/keeper/keeper_test.go | 23 +- x/protocolpool/keeper/msg_server.go | 31 +- x/protocolpool/keeper/msg_server_test.go | 106 +- x/protocolpool/module.go | 6 + .../cosmos/protocolpool/v1/genesis.proto | 20 +- x/protocolpool/types/errors.go | 4 +- x/protocolpool/types/genesis.go | 2 + x/protocolpool/types/genesis.pb.go | 355 +++++- x/protocolpool/types/keys.go | 6 +- 43 files changed, 1646 insertions(+), 553 deletions(-) create mode 100644 x/protocolpool/CHANGELOG.md diff --git a/api/cosmos/protocolpool/v1/genesis.pulsar.go b/api/cosmos/protocolpool/v1/genesis.pulsar.go index 98fc6c281211..3a7ff075f2a2 100644 --- a/api/cosmos/protocolpool/v1/genesis.pulsar.go +++ b/api/cosmos/protocolpool/v1/genesis.pulsar.go @@ -9,6 +9,7 @@ import ( protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoiface "google.golang.org/protobuf/runtime/protoiface" protoimpl "google.golang.org/protobuf/runtime/protoimpl" + timestamppb "google.golang.org/protobuf/types/known/timestamppb" io "io" reflect "reflect" sync "sync" @@ -116,11 +117,63 @@ func (x *_GenesisState_2_list) IsValid() bool { return x.list != nil } +var _ protoreflect.List = (*_GenesisState_4_list)(nil) + +type _GenesisState_4_list struct { + list *[]*Distribution +} + +func (x *_GenesisState_4_list) Len() int { + if x.list == nil { + return 0 + } + return len(*x.list) +} + +func (x *_GenesisState_4_list) Get(i int) protoreflect.Value { + return protoreflect.ValueOfMessage((*x.list)[i].ProtoReflect()) +} + +func (x *_GenesisState_4_list) Set(i int, value protoreflect.Value) { + valueUnwrapped := value.Message() + concreteValue := valueUnwrapped.Interface().(*Distribution) + (*x.list)[i] = concreteValue +} + +func (x *_GenesisState_4_list) Append(value protoreflect.Value) { + valueUnwrapped := value.Message() + concreteValue := valueUnwrapped.Interface().(*Distribution) + *x.list = append(*x.list, concreteValue) +} + +func (x *_GenesisState_4_list) AppendMutable() protoreflect.Value { + v := new(Distribution) + *x.list = append(*x.list, v) + return protoreflect.ValueOfMessage(v.ProtoReflect()) +} + +func (x *_GenesisState_4_list) Truncate(n int) { + for i := n; i < len(*x.list); i++ { + (*x.list)[i] = nil + } + *x.list = (*x.list)[:n] +} + +func (x *_GenesisState_4_list) NewElement() protoreflect.Value { + v := new(Distribution) + return protoreflect.ValueOfMessage(v.ProtoReflect()) +} + +func (x *_GenesisState_4_list) IsValid() bool { + return x.list != nil +} + var ( md_GenesisState protoreflect.MessageDescriptor fd_GenesisState_continuous_fund protoreflect.FieldDescriptor fd_GenesisState_budget protoreflect.FieldDescriptor - fd_GenesisState_to_distribute protoreflect.FieldDescriptor + fd_GenesisState_last_balance protoreflect.FieldDescriptor + fd_GenesisState_distributions protoreflect.FieldDescriptor ) func init() { @@ -128,7 +181,8 @@ func init() { md_GenesisState = File_cosmos_protocolpool_v1_genesis_proto.Messages().ByName("GenesisState") fd_GenesisState_continuous_fund = md_GenesisState.Fields().ByName("continuous_fund") fd_GenesisState_budget = md_GenesisState.Fields().ByName("budget") - fd_GenesisState_to_distribute = md_GenesisState.Fields().ByName("to_distribute") + fd_GenesisState_last_balance = md_GenesisState.Fields().ByName("last_balance") + fd_GenesisState_distributions = md_GenesisState.Fields().ByName("distributions") } var _ protoreflect.Message = (*fastReflection_GenesisState)(nil) @@ -208,9 +262,15 @@ func (x *fastReflection_GenesisState) Range(f func(protoreflect.FieldDescriptor, return } } - if x.ToDistribute != "" { - value := protoreflect.ValueOfString(x.ToDistribute) - if !f(fd_GenesisState_to_distribute, value) { + if x.LastBalance != "" { + value := protoreflect.ValueOfString(x.LastBalance) + if !f(fd_GenesisState_last_balance, value) { + return + } + } + if len(x.Distributions) != 0 { + value := protoreflect.ValueOfList(&_GenesisState_4_list{list: &x.Distributions}) + if !f(fd_GenesisState_distributions, value) { return } } @@ -233,8 +293,10 @@ func (x *fastReflection_GenesisState) Has(fd protoreflect.FieldDescriptor) bool return len(x.ContinuousFund) != 0 case "cosmos.protocolpool.v1.GenesisState.budget": return len(x.Budget) != 0 - case "cosmos.protocolpool.v1.GenesisState.to_distribute": - return x.ToDistribute != "" + case "cosmos.protocolpool.v1.GenesisState.last_balance": + return x.LastBalance != "" + case "cosmos.protocolpool.v1.GenesisState.distributions": + return len(x.Distributions) != 0 default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.protocolpool.v1.GenesisState")) @@ -255,8 +317,10 @@ func (x *fastReflection_GenesisState) Clear(fd protoreflect.FieldDescriptor) { x.ContinuousFund = nil case "cosmos.protocolpool.v1.GenesisState.budget": x.Budget = nil - case "cosmos.protocolpool.v1.GenesisState.to_distribute": - x.ToDistribute = "" + case "cosmos.protocolpool.v1.GenesisState.last_balance": + x.LastBalance = "" + case "cosmos.protocolpool.v1.GenesisState.distributions": + x.Distributions = nil default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.protocolpool.v1.GenesisState")) @@ -285,9 +349,15 @@ func (x *fastReflection_GenesisState) Get(descriptor protoreflect.FieldDescripto } listValue := &_GenesisState_2_list{list: &x.Budget} return protoreflect.ValueOfList(listValue) - case "cosmos.protocolpool.v1.GenesisState.to_distribute": - value := x.ToDistribute + case "cosmos.protocolpool.v1.GenesisState.last_balance": + value := x.LastBalance return protoreflect.ValueOfString(value) + case "cosmos.protocolpool.v1.GenesisState.distributions": + if len(x.Distributions) == 0 { + return protoreflect.ValueOfList(&_GenesisState_4_list{}) + } + listValue := &_GenesisState_4_list{list: &x.Distributions} + return protoreflect.ValueOfList(listValue) default: if descriptor.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.protocolpool.v1.GenesisState")) @@ -316,8 +386,12 @@ func (x *fastReflection_GenesisState) Set(fd protoreflect.FieldDescriptor, value lv := value.List() clv := lv.(*_GenesisState_2_list) x.Budget = *clv.list - case "cosmos.protocolpool.v1.GenesisState.to_distribute": - x.ToDistribute = value.Interface().(string) + case "cosmos.protocolpool.v1.GenesisState.last_balance": + x.LastBalance = value.Interface().(string) + case "cosmos.protocolpool.v1.GenesisState.distributions": + lv := value.List() + clv := lv.(*_GenesisState_4_list) + x.Distributions = *clv.list default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.protocolpool.v1.GenesisState")) @@ -350,8 +424,14 @@ func (x *fastReflection_GenesisState) Mutable(fd protoreflect.FieldDescriptor) p } value := &_GenesisState_2_list{list: &x.Budget} return protoreflect.ValueOfList(value) - case "cosmos.protocolpool.v1.GenesisState.to_distribute": - panic(fmt.Errorf("field to_distribute of message cosmos.protocolpool.v1.GenesisState is not mutable")) + case "cosmos.protocolpool.v1.GenesisState.distributions": + if x.Distributions == nil { + x.Distributions = []*Distribution{} + } + value := &_GenesisState_4_list{list: &x.Distributions} + return protoreflect.ValueOfList(value) + case "cosmos.protocolpool.v1.GenesisState.last_balance": + panic(fmt.Errorf("field last_balance of message cosmos.protocolpool.v1.GenesisState is not mutable")) default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.protocolpool.v1.GenesisState")) @@ -371,8 +451,11 @@ func (x *fastReflection_GenesisState) NewField(fd protoreflect.FieldDescriptor) case "cosmos.protocolpool.v1.GenesisState.budget": list := []*Budget{} return protoreflect.ValueOfList(&_GenesisState_2_list{list: &list}) - case "cosmos.protocolpool.v1.GenesisState.to_distribute": + case "cosmos.protocolpool.v1.GenesisState.last_balance": return protoreflect.ValueOfString("") + case "cosmos.protocolpool.v1.GenesisState.distributions": + list := []*Distribution{} + return protoreflect.ValueOfList(&_GenesisState_4_list{list: &list}) default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.protocolpool.v1.GenesisState")) @@ -454,10 +537,16 @@ func (x *fastReflection_GenesisState) ProtoMethods() *protoiface.Methods { n += 1 + l + runtime.Sov(uint64(l)) } } - l = len(x.ToDistribute) + l = len(x.LastBalance) if l > 0 { n += 1 + l + runtime.Sov(uint64(l)) } + if len(x.Distributions) > 0 { + for _, e := range x.Distributions { + l = options.Size(e) + n += 1 + l + runtime.Sov(uint64(l)) + } + } if x.unknownFields != nil { n += len(x.unknownFields) } @@ -487,10 +576,26 @@ func (x *fastReflection_GenesisState) ProtoMethods() *protoiface.Methods { i -= len(x.unknownFields) copy(dAtA[i:], x.unknownFields) } - if len(x.ToDistribute) > 0 { - i -= len(x.ToDistribute) - copy(dAtA[i:], x.ToDistribute) - i = runtime.EncodeVarint(dAtA, i, uint64(len(x.ToDistribute))) + if len(x.Distributions) > 0 { + for iNdEx := len(x.Distributions) - 1; iNdEx >= 0; iNdEx-- { + encoded, err := options.Marshal(x.Distributions[iNdEx]) + if err != nil { + return protoiface.MarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Buf: input.Buf, + }, err + } + i -= len(encoded) + copy(dAtA[i:], encoded) + i = runtime.EncodeVarint(dAtA, i, uint64(len(encoded))) + i-- + dAtA[i] = 0x22 + } + } + if len(x.LastBalance) > 0 { + i -= len(x.LastBalance) + copy(dAtA[i:], x.LastBalance) + i = runtime.EncodeVarint(dAtA, i, uint64(len(x.LastBalance))) i-- dAtA[i] = 0x1a } @@ -645,7 +750,7 @@ func (x *fastReflection_GenesisState) ProtoMethods() *protoiface.Methods { iNdEx = postIndex case 3: if wireType != 2 { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field ToDistribute", wireType) + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field LastBalance", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -673,7 +778,41 @@ func (x *fastReflection_GenesisState) ProtoMethods() *protoiface.Methods { if postIndex > l { return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF } - x.ToDistribute = string(dAtA[iNdEx:postIndex]) + x.LastBalance = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 2 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field Distributions", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if postIndex > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + x.Distributions = append(x.Distributions, &Distribution{}) + if err := options.Unmarshal(dAtA[iNdEx:postIndex], x.Distributions[len(x.Distributions)-1]); err != nil { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err + } iNdEx = postIndex default: iNdEx = preIndex @@ -710,154 +849,740 @@ func (x *fastReflection_GenesisState) ProtoMethods() *protoiface.Methods { } } -// Code generated by protoc-gen-go. DO NOT EDIT. -// versions: -// protoc-gen-go v1.27.0 -// protoc (unknown) -// source: cosmos/protocolpool/v1/genesis.proto - -const ( - // Verify that this generated code is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) - // Verify that runtime/protoimpl is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +var ( + md_Distribution protoreflect.MessageDescriptor + fd_Distribution_amount protoreflect.FieldDescriptor + fd_Distribution_time protoreflect.FieldDescriptor ) -// GenesisState defines the protocolpool module's genesis state. -type GenesisState struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields +func init() { + file_cosmos_protocolpool_v1_genesis_proto_init() + md_Distribution = File_cosmos_protocolpool_v1_genesis_proto.Messages().ByName("Distribution") + fd_Distribution_amount = md_Distribution.Fields().ByName("amount") + fd_Distribution_time = md_Distribution.Fields().ByName("time") +} - // ContinuousFund defines the continuous funds at genesis. - ContinuousFund []*ContinuousFund `protobuf:"bytes,1,rep,name=continuous_fund,json=continuousFund,proto3" json:"continuous_fund,omitempty"` - // Budget defines the budget proposals at genesis. - Budget []*Budget `protobuf:"bytes,2,rep,name=budget,proto3" json:"budget,omitempty"` - ToDistribute string `protobuf:"bytes,3,opt,name=to_distribute,json=toDistribute,proto3" json:"to_distribute,omitempty"` +var _ protoreflect.Message = (*fastReflection_Distribution)(nil) + +type fastReflection_Distribution Distribution + +func (x *Distribution) ProtoReflect() protoreflect.Message { + return (*fastReflection_Distribution)(x) } -func (x *GenesisState) Reset() { - *x = GenesisState{} - if protoimpl.UnsafeEnabled { - mi := &file_cosmos_protocolpool_v1_genesis_proto_msgTypes[0] +func (x *Distribution) slowProtoReflect() protoreflect.Message { + mi := &file_cosmos_protocolpool_v1_genesis_proto_msgTypes[1] + if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms } + return mi.MessageOf(x) } -func (x *GenesisState) String() string { - return protoimpl.X.MessageStringOf(x) -} +var _fastReflection_Distribution_messageType fastReflection_Distribution_messageType +var _ protoreflect.MessageType = fastReflection_Distribution_messageType{} -func (*GenesisState) ProtoMessage() {} +type fastReflection_Distribution_messageType struct{} -// Deprecated: Use GenesisState.ProtoReflect.Descriptor instead. -func (*GenesisState) Descriptor() ([]byte, []int) { - return file_cosmos_protocolpool_v1_genesis_proto_rawDescGZIP(), []int{0} +func (x fastReflection_Distribution_messageType) Zero() protoreflect.Message { + return (*fastReflection_Distribution)(nil) } - -func (x *GenesisState) GetContinuousFund() []*ContinuousFund { - if x != nil { - return x.ContinuousFund - } - return nil +func (x fastReflection_Distribution_messageType) New() protoreflect.Message { + return new(fastReflection_Distribution) +} +func (x fastReflection_Distribution_messageType) Descriptor() protoreflect.MessageDescriptor { + return md_Distribution } -func (x *GenesisState) GetBudget() []*Budget { - if x != nil { - return x.Budget - } - return nil +// Descriptor returns message descriptor, which contains only the protobuf +// type information for the message. +func (x *fastReflection_Distribution) Descriptor() protoreflect.MessageDescriptor { + return md_Distribution } -func (x *GenesisState) GetToDistribute() string { - if x != nil { - return x.ToDistribute - } - return "" +// 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_Distribution) Type() protoreflect.MessageType { + return _fastReflection_Distribution_messageType } -var File_cosmos_protocolpool_v1_genesis_proto protoreflect.FileDescriptor +// New returns a newly allocated and mutable empty message. +func (x *fastReflection_Distribution) New() protoreflect.Message { + return new(fastReflection_Distribution) +} -var file_cosmos_protocolpool_v1_genesis_proto_rawDesc = []byte{ - 0x0a, 0x24, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, - 0x6c, 0x70, 0x6f, 0x6f, 0x6c, 0x2f, 0x76, 0x31, 0x2f, 0x67, 0x65, 0x6e, 0x65, 0x73, 0x69, 0x73, - 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x16, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x70, - 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x70, 0x6f, 0x6f, 0x6c, 0x2e, 0x76, 0x31, 0x1a, 0x22, - 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x70, - 0x6f, 0x6f, 0x6c, 0x2f, 0x76, 0x31, 0x2f, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2e, 0x70, 0x72, 0x6f, - 0x74, 0x6f, 0x1a, 0x14, 0x67, 0x6f, 0x67, 0x6f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x67, 0x6f, - 0x67, 0x6f, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x19, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, - 0x5f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x22, 0xe9, 0x01, 0x0a, 0x0c, 0x47, 0x65, 0x6e, 0x65, 0x73, 0x69, 0x73, 0x53, - 0x74, 0x61, 0x74, 0x65, 0x12, 0x4f, 0x0a, 0x0f, 0x63, 0x6f, 0x6e, 0x74, 0x69, 0x6e, 0x75, 0x6f, - 0x75, 0x73, 0x5f, 0x66, 0x75, 0x6e, 0x64, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x26, 0x2e, - 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x70, - 0x6f, 0x6f, 0x6c, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x6f, 0x6e, 0x74, 0x69, 0x6e, 0x75, 0x6f, 0x75, - 0x73, 0x46, 0x75, 0x6e, 0x64, 0x52, 0x0e, 0x63, 0x6f, 0x6e, 0x74, 0x69, 0x6e, 0x75, 0x6f, 0x75, - 0x73, 0x46, 0x75, 0x6e, 0x64, 0x12, 0x36, 0x0a, 0x06, 0x62, 0x75, 0x64, 0x67, 0x65, 0x74, 0x18, - 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1e, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x70, - 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x70, 0x6f, 0x6f, 0x6c, 0x2e, 0x76, 0x31, 0x2e, 0x42, - 0x75, 0x64, 0x67, 0x65, 0x74, 0x52, 0x06, 0x62, 0x75, 0x64, 0x67, 0x65, 0x74, 0x12, 0x50, 0x0a, - 0x0d, 0x74, 0x6f, 0x5f, 0x64, 0x69, 0x73, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x18, 0x03, - 0x20, 0x01, 0x28, 0x09, 0x42, 0x2b, 0xc8, 0xde, 0x1f, 0x00, 0xda, 0xde, 0x1f, 0x15, 0x63, 0x6f, - 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x6d, 0x61, 0x74, 0x68, 0x2e, - 0x49, 0x6e, 0x74, 0xd2, 0xb4, 0x2d, 0x0a, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x49, 0x6e, - 0x74, 0x52, 0x0c, 0x74, 0x6f, 0x44, 0x69, 0x73, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x42, - 0xdc, 0x01, 0x0a, 0x1a, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x70, - 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x70, 0x6f, 0x6f, 0x6c, 0x2e, 0x76, 0x31, 0x42, 0x0c, - 0x47, 0x65, 0x6e, 0x65, 0x73, 0x69, 0x73, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x36, - 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x61, 0x70, 0x69, - 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, - 0x70, 0x6f, 0x6f, 0x6c, 0x2f, 0x76, 0x31, 0x3b, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, - 0x70, 0x6f, 0x6f, 0x6c, 0x76, 0x31, 0xa2, 0x02, 0x03, 0x43, 0x50, 0x58, 0xaa, 0x02, 0x16, 0x43, - 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x70, 0x6f, - 0x6f, 0x6c, 0x2e, 0x56, 0x31, 0xca, 0x02, 0x16, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x5c, 0x50, - 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x70, 0x6f, 0x6f, 0x6c, 0x5c, 0x56, 0x31, 0xe2, 0x02, - 0x22, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x5c, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, - 0x70, 0x6f, 0x6f, 0x6c, 0x5c, 0x56, 0x31, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, - 0x61, 0x74, 0x61, 0xea, 0x02, 0x18, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x3a, 0x3a, 0x50, 0x72, - 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x70, 0x6f, 0x6f, 0x6c, 0x3a, 0x3a, 0x56, 0x31, 0x62, 0x06, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +// Interface unwraps the message reflection interface and +// returns the underlying ProtoMessage interface. +func (x *fastReflection_Distribution) Interface() protoreflect.ProtoMessage { + return (*Distribution)(x) } -var ( - file_cosmos_protocolpool_v1_genesis_proto_rawDescOnce sync.Once - file_cosmos_protocolpool_v1_genesis_proto_rawDescData = file_cosmos_protocolpool_v1_genesis_proto_rawDesc -) +// 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_Distribution) Range(f func(protoreflect.FieldDescriptor, protoreflect.Value) bool) { + if x.Amount != "" { + value := protoreflect.ValueOfString(x.Amount) + if !f(fd_Distribution_amount, value) { + return + } + } + if x.Time != nil { + value := protoreflect.ValueOfMessage(x.Time.ProtoReflect()) + if !f(fd_Distribution_time, value) { + return + } + } +} -func file_cosmos_protocolpool_v1_genesis_proto_rawDescGZIP() []byte { - file_cosmos_protocolpool_v1_genesis_proto_rawDescOnce.Do(func() { - file_cosmos_protocolpool_v1_genesis_proto_rawDescData = protoimpl.X.CompressGZIP(file_cosmos_protocolpool_v1_genesis_proto_rawDescData) - }) - return file_cosmos_protocolpool_v1_genesis_proto_rawDescData +// 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_Distribution) Has(fd protoreflect.FieldDescriptor) bool { + switch fd.FullName() { + case "cosmos.protocolpool.v1.Distribution.amount": + return x.Amount != "" + case "cosmos.protocolpool.v1.Distribution.time": + return x.Time != nil + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.protocolpool.v1.Distribution")) + } + panic(fmt.Errorf("message cosmos.protocolpool.v1.Distribution does not contain field %s", fd.FullName())) + } } -var file_cosmos_protocolpool_v1_genesis_proto_msgTypes = make([]protoimpl.MessageInfo, 1) -var file_cosmos_protocolpool_v1_genesis_proto_goTypes = []interface{}{ - (*GenesisState)(nil), // 0: cosmos.protocolpool.v1.GenesisState - (*ContinuousFund)(nil), // 1: cosmos.protocolpool.v1.ContinuousFund - (*Budget)(nil), // 2: cosmos.protocolpool.v1.Budget +// 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_Distribution) Clear(fd protoreflect.FieldDescriptor) { + switch fd.FullName() { + case "cosmos.protocolpool.v1.Distribution.amount": + x.Amount = "" + case "cosmos.protocolpool.v1.Distribution.time": + x.Time = nil + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.protocolpool.v1.Distribution")) + } + panic(fmt.Errorf("message cosmos.protocolpool.v1.Distribution does not contain field %s", fd.FullName())) + } } -var file_cosmos_protocolpool_v1_genesis_proto_depIdxs = []int32{ - 1, // 0: cosmos.protocolpool.v1.GenesisState.continuous_fund:type_name -> cosmos.protocolpool.v1.ContinuousFund - 2, // 1: cosmos.protocolpool.v1.GenesisState.budget:type_name -> cosmos.protocolpool.v1.Budget - 2, // [2:2] is the sub-list for method output_type - 2, // [2:2] is the sub-list for method input_type - 2, // [2:2] is the sub-list for extension type_name - 2, // [2:2] is the sub-list for extension extendee - 0, // [0:2] is the sub-list for field type_name + +// 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_Distribution) Get(descriptor protoreflect.FieldDescriptor) protoreflect.Value { + switch descriptor.FullName() { + case "cosmos.protocolpool.v1.Distribution.amount": + value := x.Amount + return protoreflect.ValueOfString(value) + case "cosmos.protocolpool.v1.Distribution.time": + value := x.Time + return protoreflect.ValueOfMessage(value.ProtoReflect()) + default: + if descriptor.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.protocolpool.v1.Distribution")) + } + panic(fmt.Errorf("message cosmos.protocolpool.v1.Distribution does not contain field %s", descriptor.FullName())) + } } -func init() { file_cosmos_protocolpool_v1_genesis_proto_init() } -func file_cosmos_protocolpool_v1_genesis_proto_init() { - if File_cosmos_protocolpool_v1_genesis_proto != nil { - return +// 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_Distribution) Set(fd protoreflect.FieldDescriptor, value protoreflect.Value) { + switch fd.FullName() { + case "cosmos.protocolpool.v1.Distribution.amount": + x.Amount = value.Interface().(string) + case "cosmos.protocolpool.v1.Distribution.time": + x.Time = value.Message().Interface().(*timestamppb.Timestamp) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.protocolpool.v1.Distribution")) + } + panic(fmt.Errorf("message cosmos.protocolpool.v1.Distribution does not contain field %s", fd.FullName())) } - file_cosmos_protocolpool_v1_types_proto_init() - if !protoimpl.UnsafeEnabled { - file_cosmos_protocolpool_v1_genesis_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*GenesisState); i { +} + +// 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_Distribution) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + case "cosmos.protocolpool.v1.Distribution.time": + if x.Time == nil { + x.Time = new(timestamppb.Timestamp) + } + return protoreflect.ValueOfMessage(x.Time.ProtoReflect()) + case "cosmos.protocolpool.v1.Distribution.amount": + panic(fmt.Errorf("field amount of message cosmos.protocolpool.v1.Distribution is not mutable")) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.protocolpool.v1.Distribution")) + } + panic(fmt.Errorf("message cosmos.protocolpool.v1.Distribution 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_Distribution) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + case "cosmos.protocolpool.v1.Distribution.amount": + return protoreflect.ValueOfString("") + case "cosmos.protocolpool.v1.Distribution.time": + m := new(timestamppb.Timestamp) + return protoreflect.ValueOfMessage(m.ProtoReflect()) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.protocolpool.v1.Distribution")) + } + panic(fmt.Errorf("message cosmos.protocolpool.v1.Distribution 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_Distribution) WhichOneof(d protoreflect.OneofDescriptor) protoreflect.FieldDescriptor { + switch d.FullName() { + default: + panic(fmt.Errorf("%s is not a oneof field in cosmos.protocolpool.v1.Distribution", 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_Distribution) 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_Distribution) 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_Distribution) 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_Distribution) ProtoMethods() *protoiface.Methods { + size := func(input protoiface.SizeInput) protoiface.SizeOutput { + x := input.Message.Interface().(*Distribution) + if x == nil { + return protoiface.SizeOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Size: 0, + } + } + options := runtime.SizeInputToOptions(input) + _ = options + var n int + var l int + _ = l + l = len(x.Amount) + if l > 0 { + n += 1 + l + runtime.Sov(uint64(l)) + } + if x.Time != nil { + l = options.Size(x.Time) + n += 1 + l + runtime.Sov(uint64(l)) + } + if x.unknownFields != nil { + n += len(x.unknownFields) + } + return protoiface.SizeOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Size: n, + } + } + + marshal := func(input protoiface.MarshalInput) (protoiface.MarshalOutput, error) { + x := input.Message.Interface().(*Distribution) + 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.Time != nil { + encoded, err := options.Marshal(x.Time) + if err != nil { + return protoiface.MarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Buf: input.Buf, + }, err + } + i -= len(encoded) + copy(dAtA[i:], encoded) + i = runtime.EncodeVarint(dAtA, i, uint64(len(encoded))) + i-- + dAtA[i] = 0x32 + } + if len(x.Amount) > 0 { + i -= len(x.Amount) + copy(dAtA[i:], x.Amount) + i = runtime.EncodeVarint(dAtA, i, uint64(len(x.Amount))) + i-- + dAtA[i] = 0x1a + } + 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().(*Distribution) + 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: Distribution: wiretype end group for non-group") + } + if fieldNum <= 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: Distribution: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 3: + if wireType != 2 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field Amount", 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.Amount = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 6: + if wireType != 2 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field Time", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if postIndex > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + if x.Time == nil { + x.Time = ×tamppb.Timestamp{} + } + if err := options.Unmarshal(dAtA[iNdEx:postIndex], x.Time); err != nil { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := runtime.Skip(dAtA[iNdEx:]) + if err != nil { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + if !options.DiscardUnknown { + x.unknownFields = append(x.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + } + iNdEx += skippy + } + } + + if iNdEx > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, nil + } + return &protoiface.Methods{ + NoUnkeyedLiterals: struct{}{}, + Flags: protoiface.SupportMarshalDeterministic | protoiface.SupportUnmarshalDiscardUnknown, + Size: size, + Marshal: marshal, + Unmarshal: unmarshal, + Merge: nil, + CheckInitialized: nil, + } +} + +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.27.0 +// protoc (unknown) +// source: cosmos/protocolpool/v1/genesis.proto + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +// GenesisState defines the protocolpool module's genesis state. +type GenesisState struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // ContinuousFund defines the continuous funds at genesis. + ContinuousFund []*ContinuousFund `protobuf:"bytes,1,rep,name=continuous_fund,json=continuousFund,proto3" json:"continuous_fund,omitempty"` + // Budget defines the budget proposals at genesis. + Budget []*Budget `protobuf:"bytes,2,rep,name=budget,proto3" json:"budget,omitempty"` + // last_balance contains the amount of tokens yet to be distributed, will be zero if + // there are no funds to distribute. + LastBalance string `protobuf:"bytes,3,opt,name=last_balance,json=lastBalance,proto3" json:"last_balance,omitempty"` + // distributions contains the list of distributions to be made to continuous + // funds and budgets. It contains time in order to distribute to non-expired + // funds only. + Distributions []*Distribution `protobuf:"bytes,4,rep,name=distributions,proto3" json:"distributions,omitempty"` +} + +func (x *GenesisState) Reset() { + *x = GenesisState{} + if protoimpl.UnsafeEnabled { + mi := &file_cosmos_protocolpool_v1_genesis_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *GenesisState) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GenesisState) ProtoMessage() {} + +// Deprecated: Use GenesisState.ProtoReflect.Descriptor instead. +func (*GenesisState) Descriptor() ([]byte, []int) { + return file_cosmos_protocolpool_v1_genesis_proto_rawDescGZIP(), []int{0} +} + +func (x *GenesisState) GetContinuousFund() []*ContinuousFund { + if x != nil { + return x.ContinuousFund + } + return nil +} + +func (x *GenesisState) GetBudget() []*Budget { + if x != nil { + return x.Budget + } + return nil +} + +func (x *GenesisState) GetLastBalance() string { + if x != nil { + return x.LastBalance + } + return "" +} + +func (x *GenesisState) GetDistributions() []*Distribution { + if x != nil { + return x.Distributions + } + return nil +} + +type Distribution struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Amount string `protobuf:"bytes,3,opt,name=amount,proto3" json:"amount,omitempty"` + Time *timestamppb.Timestamp `protobuf:"bytes,6,opt,name=time,proto3" json:"time,omitempty"` +} + +func (x *Distribution) Reset() { + *x = Distribution{} + if protoimpl.UnsafeEnabled { + mi := &file_cosmos_protocolpool_v1_genesis_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Distribution) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Distribution) ProtoMessage() {} + +// Deprecated: Use Distribution.ProtoReflect.Descriptor instead. +func (*Distribution) Descriptor() ([]byte, []int) { + return file_cosmos_protocolpool_v1_genesis_proto_rawDescGZIP(), []int{1} +} + +func (x *Distribution) GetAmount() string { + if x != nil { + return x.Amount + } + return "" +} + +func (x *Distribution) GetTime() *timestamppb.Timestamp { + if x != nil { + return x.Time + } + return nil +} + +var File_cosmos_protocolpool_v1_genesis_proto protoreflect.FileDescriptor + +var file_cosmos_protocolpool_v1_genesis_proto_rawDesc = []byte{ + 0x0a, 0x24, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, + 0x6c, 0x70, 0x6f, 0x6f, 0x6c, 0x2f, 0x76, 0x31, 0x2f, 0x67, 0x65, 0x6e, 0x65, 0x73, 0x69, 0x73, + 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x16, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x70, 0x6f, 0x6f, 0x6c, 0x2e, 0x76, 0x31, 0x1a, 0x22, + 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x70, + 0x6f, 0x6f, 0x6c, 0x2f, 0x76, 0x31, 0x2f, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2e, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x1a, 0x14, 0x67, 0x6f, 0x67, 0x6f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x67, 0x6f, + 0x67, 0x6f, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x19, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, + 0x5f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x1a, 0x1f, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x2e, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xb3, 0x02, 0x0a, 0x0c, 0x47, 0x65, 0x6e, 0x65, 0x73, 0x69, 0x73, + 0x53, 0x74, 0x61, 0x74, 0x65, 0x12, 0x4f, 0x0a, 0x0f, 0x63, 0x6f, 0x6e, 0x74, 0x69, 0x6e, 0x75, + 0x6f, 0x75, 0x73, 0x5f, 0x66, 0x75, 0x6e, 0x64, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x26, + 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, + 0x70, 0x6f, 0x6f, 0x6c, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x6f, 0x6e, 0x74, 0x69, 0x6e, 0x75, 0x6f, + 0x75, 0x73, 0x46, 0x75, 0x6e, 0x64, 0x52, 0x0e, 0x63, 0x6f, 0x6e, 0x74, 0x69, 0x6e, 0x75, 0x6f, + 0x75, 0x73, 0x46, 0x75, 0x6e, 0x64, 0x12, 0x36, 0x0a, 0x06, 0x62, 0x75, 0x64, 0x67, 0x65, 0x74, + 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1e, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x70, 0x6f, 0x6f, 0x6c, 0x2e, 0x76, 0x31, 0x2e, + 0x42, 0x75, 0x64, 0x67, 0x65, 0x74, 0x52, 0x06, 0x62, 0x75, 0x64, 0x67, 0x65, 0x74, 0x12, 0x4e, + 0x0a, 0x0c, 0x6c, 0x61, 0x73, 0x74, 0x5f, 0x62, 0x61, 0x6c, 0x61, 0x6e, 0x63, 0x65, 0x18, 0x03, + 0x20, 0x01, 0x28, 0x09, 0x42, 0x2b, 0xc8, 0xde, 0x1f, 0x00, 0xda, 0xde, 0x1f, 0x15, 0x63, 0x6f, + 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x6d, 0x61, 0x74, 0x68, 0x2e, + 0x49, 0x6e, 0x74, 0xd2, 0xb4, 0x2d, 0x0a, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x49, 0x6e, + 0x74, 0x52, 0x0b, 0x6c, 0x61, 0x73, 0x74, 0x42, 0x61, 0x6c, 0x61, 0x6e, 0x63, 0x65, 0x12, 0x4a, + 0x0a, 0x0d, 0x64, 0x69, 0x73, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, + 0x04, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x24, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x70, 0x6f, 0x6f, 0x6c, 0x2e, 0x76, 0x31, 0x2e, 0x44, + 0x69, 0x73, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x0d, 0x64, 0x69, 0x73, + 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x22, 0x89, 0x01, 0x0a, 0x0c, 0x44, + 0x69, 0x73, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x43, 0x0a, 0x06, 0x61, + 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x42, 0x2b, 0xc8, 0xde, 0x1f, + 0x00, 0xda, 0xde, 0x1f, 0x15, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, + 0x6f, 0x2f, 0x6d, 0x61, 0x74, 0x68, 0x2e, 0x49, 0x6e, 0x74, 0xd2, 0xb4, 0x2d, 0x0a, 0x63, 0x6f, + 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x49, 0x6e, 0x74, 0x52, 0x06, 0x61, 0x6d, 0x6f, 0x75, 0x6e, 0x74, + 0x12, 0x34, 0x0a, 0x04, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, + 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, + 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x42, 0x04, 0x90, 0xdf, 0x1f, 0x01, + 0x52, 0x04, 0x74, 0x69, 0x6d, 0x65, 0x42, 0xdc, 0x01, 0x0a, 0x1a, 0x63, 0x6f, 0x6d, 0x2e, 0x63, + 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x70, 0x6f, + 0x6f, 0x6c, 0x2e, 0x76, 0x31, 0x42, 0x0c, 0x47, 0x65, 0x6e, 0x65, 0x73, 0x69, 0x73, 0x50, 0x72, + 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x36, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, + 0x2e, 0x69, 0x6f, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x70, 0x6f, 0x6f, 0x6c, 0x2f, 0x76, 0x31, 0x3b, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x70, 0x6f, 0x6f, 0x6c, 0x76, 0x31, 0xa2, 0x02, 0x03, + 0x43, 0x50, 0x58, 0xaa, 0x02, 0x16, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x50, 0x72, 0x6f, + 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x70, 0x6f, 0x6f, 0x6c, 0x2e, 0x56, 0x31, 0xca, 0x02, 0x16, 0x43, + 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x5c, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x70, 0x6f, + 0x6f, 0x6c, 0x5c, 0x56, 0x31, 0xe2, 0x02, 0x22, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x5c, 0x50, + 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x70, 0x6f, 0x6f, 0x6c, 0x5c, 0x56, 0x31, 0x5c, 0x47, + 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x18, 0x43, 0x6f, 0x73, + 0x6d, 0x6f, 0x73, 0x3a, 0x3a, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x70, 0x6f, 0x6f, + 0x6c, 0x3a, 0x3a, 0x56, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_cosmos_protocolpool_v1_genesis_proto_rawDescOnce sync.Once + file_cosmos_protocolpool_v1_genesis_proto_rawDescData = file_cosmos_protocolpool_v1_genesis_proto_rawDesc +) + +func file_cosmos_protocolpool_v1_genesis_proto_rawDescGZIP() []byte { + file_cosmos_protocolpool_v1_genesis_proto_rawDescOnce.Do(func() { + file_cosmos_protocolpool_v1_genesis_proto_rawDescData = protoimpl.X.CompressGZIP(file_cosmos_protocolpool_v1_genesis_proto_rawDescData) + }) + return file_cosmos_protocolpool_v1_genesis_proto_rawDescData +} + +var file_cosmos_protocolpool_v1_genesis_proto_msgTypes = make([]protoimpl.MessageInfo, 2) +var file_cosmos_protocolpool_v1_genesis_proto_goTypes = []interface{}{ + (*GenesisState)(nil), // 0: cosmos.protocolpool.v1.GenesisState + (*Distribution)(nil), // 1: cosmos.protocolpool.v1.Distribution + (*ContinuousFund)(nil), // 2: cosmos.protocolpool.v1.ContinuousFund + (*Budget)(nil), // 3: cosmos.protocolpool.v1.Budget + (*timestamppb.Timestamp)(nil), // 4: google.protobuf.Timestamp +} +var file_cosmos_protocolpool_v1_genesis_proto_depIdxs = []int32{ + 2, // 0: cosmos.protocolpool.v1.GenesisState.continuous_fund:type_name -> cosmos.protocolpool.v1.ContinuousFund + 3, // 1: cosmos.protocolpool.v1.GenesisState.budget:type_name -> cosmos.protocolpool.v1.Budget + 1, // 2: cosmos.protocolpool.v1.GenesisState.distributions:type_name -> cosmos.protocolpool.v1.Distribution + 4, // 3: cosmos.protocolpool.v1.Distribution.time:type_name -> google.protobuf.Timestamp + 4, // [4:4] is the sub-list for method output_type + 4, // [4:4] is the sub-list for method input_type + 4, // [4:4] is the sub-list for extension type_name + 4, // [4:4] is the sub-list for extension extendee + 0, // [0:4] is the sub-list for field type_name +} + +func init() { file_cosmos_protocolpool_v1_genesis_proto_init() } +func file_cosmos_protocolpool_v1_genesis_proto_init() { + if File_cosmos_protocolpool_v1_genesis_proto != nil { + return + } + file_cosmos_protocolpool_v1_types_proto_init() + if !protoimpl.UnsafeEnabled { + file_cosmos_protocolpool_v1_genesis_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*GenesisState); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_cosmos_protocolpool_v1_genesis_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Distribution); i { case 0: return &v.state case 1: @@ -875,7 +1600,7 @@ func file_cosmos_protocolpool_v1_genesis_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_cosmos_protocolpool_v1_genesis_proto_rawDesc, NumEnums: 0, - NumMessages: 1, + NumMessages: 2, NumExtensions: 0, NumServices: 0, }, diff --git a/simapp/app.go b/simapp/app.go index 96366c85abcc..df3e524922d6 100644 --- a/simapp/app.go +++ b/simapp/app.go @@ -19,7 +19,6 @@ import ( reflectionv1 "cosmossdk.io/api/cosmos/reflection/v1" "cosmossdk.io/client/v2/autocli" clienthelpers "cosmossdk.io/client/v2/helpers" - "cosmossdk.io/core/appmodule" "cosmossdk.io/core/log" storetypes "cosmossdk.io/store/types" "cosmossdk.io/x/accounts" @@ -124,15 +123,16 @@ var ( // module account permissions maccPerms = map[string][]string{ - authtypes.FeeCollectorName: nil, - distrtypes.ModuleName: nil, - pooltypes.ModuleName: nil, - pooltypes.StreamAccount: nil, - minttypes.ModuleName: {authtypes.Minter}, - stakingtypes.BondedPoolName: {authtypes.Burner, authtypes.Staking}, - stakingtypes.NotBondedPoolName: {authtypes.Burner, authtypes.Staking}, - govtypes.ModuleName: {authtypes.Burner}, - nft.ModuleName: nil, + authtypes.FeeCollectorName: nil, + distrtypes.ModuleName: nil, + pooltypes.ModuleName: nil, + pooltypes.StreamAccount: nil, + pooltypes.ProtocolPoolDistrAccount: nil, + minttypes.ModuleName: {authtypes.Minter}, + stakingtypes.BondedPoolName: {authtypes.Burner, authtypes.Staking}, + stakingtypes.NotBondedPoolName: {authtypes.Burner, authtypes.Staking}, + govtypes.ModuleName: {authtypes.Burner}, + nft.ModuleName: nil, } ) @@ -354,7 +354,7 @@ func NewSimApp( app.PoolKeeper = poolkeeper.NewKeeper(appCodec, runtime.NewEnvironment(runtime.NewKVStoreService(keys[pooltypes.StoreKey]), logger.With(log.ModuleKey, "x/protocolpool")), app.AuthKeeper, app.BankKeeper, app.StakingKeeper, authtypes.NewModuleAddress(govtypes.ModuleName).String()) - app.DistrKeeper = distrkeeper.NewKeeper(appCodec, runtime.NewEnvironment(runtime.NewKVStoreService(keys[distrtypes.StoreKey]), logger.With(log.ModuleKey, "x/distribution")), app.AuthKeeper, app.BankKeeper, app.StakingKeeper, app.PoolKeeper, cometService, authtypes.FeeCollectorName, authtypes.NewModuleAddress(govtypes.ModuleName).String()) + app.DistrKeeper = distrkeeper.NewKeeper(appCodec, runtime.NewEnvironment(runtime.NewKVStoreService(keys[distrtypes.StoreKey]), logger.With(log.ModuleKey, "x/distribution")), app.AuthKeeper, app.BankKeeper, app.StakingKeeper, cometService, authtypes.FeeCollectorName, authtypes.NewModuleAddress(govtypes.ModuleName).String()) app.SlashingKeeper = slashingkeeper.NewKeeper(runtime.NewEnvironment(runtime.NewKVStoreService(keys[slashingtypes.StoreKey]), logger.With(log.ModuleKey, "x/slashing")), appCodec, legacyAmino, app.StakingKeeper, authtypes.NewModuleAddress(govtypes.ModuleName).String(), @@ -437,28 +437,28 @@ func NewSimApp( // NOTE: Any module instantiated in the module manager that is later modified // must be passed by reference here. - app.ModuleManager = module.NewManagerFromMap(map[string]appmodule.AppModule{ - genutiltypes.ModuleName: genutil.NewAppModule(appCodec, app.AuthKeeper, app.StakingKeeper, app, txConfig, genutiltypes.DefaultMessageValidator), - accounts.ModuleName: accounts.NewAppModule(appCodec, app.AccountsKeeper), - authtypes.ModuleName: auth.NewAppModule(appCodec, app.AuthKeeper, app.AccountsKeeper, authsims.RandomGenesisAccounts), - vestingtypes.ModuleName: vesting.NewAppModule(app.AuthKeeper, app.BankKeeper), - banktypes.ModuleName: bank.NewAppModule(appCodec, app.BankKeeper, app.AuthKeeper), - feegrant.ModuleName: feegrantmodule.NewAppModule(appCodec, app.AuthKeeper, app.BankKeeper, app.FeeGrantKeeper, app.interfaceRegistry), - govtypes.ModuleName: gov.NewAppModule(appCodec, &app.GovKeeper, app.AuthKeeper, app.BankKeeper, app.PoolKeeper), - minttypes.ModuleName: mint.NewAppModule(appCodec, app.MintKeeper, app.AuthKeeper, nil), - slashingtypes.ModuleName: slashing.NewAppModule(appCodec, app.SlashingKeeper, app.AuthKeeper, app.BankKeeper, app.StakingKeeper, app.interfaceRegistry, cometService), - distrtypes.ModuleName: distr.NewAppModule(appCodec, app.DistrKeeper, app.AuthKeeper, app.BankKeeper, app.StakingKeeper, app.PoolKeeper), - stakingtypes.ModuleName: staking.NewAppModule(appCodec, app.StakingKeeper, app.AuthKeeper, app.BankKeeper), - upgradetypes.ModuleName: upgrade.NewAppModule(app.UpgradeKeeper), - evidencetypes.ModuleName: evidence.NewAppModule(appCodec, app.EvidenceKeeper, cometService), - authz.ModuleName: authzmodule.NewAppModule(appCodec, app.AuthzKeeper, app.AuthKeeper, app.BankKeeper, app.interfaceRegistry), - group.ModuleName: groupmodule.NewAppModule(appCodec, app.GroupKeeper, app.AuthKeeper, app.BankKeeper, app.interfaceRegistry), - nft.ModuleName: nftmodule.NewAppModule(appCodec, app.NFTKeeper, app.AuthKeeper, app.BankKeeper, app.interfaceRegistry), - consensusparamtypes.ModuleName: consensus.NewAppModule(appCodec, app.ConsensusParamsKeeper), - circuittypes.ModuleName: circuit.NewAppModule(appCodec, app.CircuitKeeper), - pooltypes.ModuleName: protocolpool.NewAppModule(appCodec, app.PoolKeeper, app.AuthKeeper, app.BankKeeper), - epochstypes.ModuleName: epochs.NewAppModule(appCodec, app.EpochsKeeper), - }) + app.ModuleManager = module.NewManager( + genutil.NewAppModule(appCodec, app.AuthKeeper, app.StakingKeeper, app, txConfig, genutiltypes.DefaultMessageValidator), + accounts.NewAppModule(appCodec, app.AccountsKeeper), + auth.NewAppModule(appCodec, app.AuthKeeper, app.AccountsKeeper, authsims.RandomGenesisAccounts), + vesting.NewAppModule(app.AuthKeeper, app.BankKeeper), + bank.NewAppModule(appCodec, app.BankKeeper, app.AuthKeeper), + feegrantmodule.NewAppModule(appCodec, app.AuthKeeper, app.BankKeeper, app.FeeGrantKeeper, app.interfaceRegistry), + gov.NewAppModule(appCodec, &app.GovKeeper, app.AuthKeeper, app.BankKeeper, app.PoolKeeper), + mint.NewAppModule(appCodec, app.MintKeeper, app.AuthKeeper, nil), + slashing.NewAppModule(appCodec, app.SlashingKeeper, app.AuthKeeper, app.BankKeeper, app.StakingKeeper, app.interfaceRegistry, cometService), + distr.NewAppModule(appCodec, app.DistrKeeper, app.AuthKeeper, app.BankKeeper, app.StakingKeeper), + staking.NewAppModule(appCodec, app.StakingKeeper, app.AuthKeeper, app.BankKeeper), + upgrade.NewAppModule(app.UpgradeKeeper), + evidence.NewAppModule(appCodec, app.EvidenceKeeper, cometService), + authzmodule.NewAppModule(appCodec, app.AuthzKeeper, app.AuthKeeper, app.BankKeeper, app.interfaceRegistry), + groupmodule.NewAppModule(appCodec, app.GroupKeeper, app.AuthKeeper, app.BankKeeper, app.interfaceRegistry), + nftmodule.NewAppModule(appCodec, app.NFTKeeper, app.AuthKeeper, app.BankKeeper, app.interfaceRegistry), + consensus.NewAppModule(appCodec, app.ConsensusParamsKeeper), + circuit.NewAppModule(appCodec, app.CircuitKeeper), + protocolpool.NewAppModule(appCodec, app.PoolKeeper, app.AuthKeeper, app.BankKeeper), + epochs.NewAppModule(appCodec, app.EpochsKeeper), + ) app.ModuleManager.RegisterLegacyAminoCodec(legacyAmino) app.ModuleManager.RegisterInterfaces(interfaceRegistry) @@ -474,6 +474,7 @@ func NewSimApp( app.ModuleManager.SetOrderBeginBlockers( minttypes.ModuleName, distrtypes.ModuleName, + pooltypes.ModuleName, slashingtypes.ModuleName, evidencetypes.ModuleName, stakingtypes.ModuleName, diff --git a/simapp/app_config.go b/simapp/app_config.go index 4eb39f1766c7..e92ac2ce03fe 100644 --- a/simapp/app_config.go +++ b/simapp/app_config.go @@ -81,6 +81,7 @@ var ( {Account: distrtypes.ModuleName}, {Account: pooltypes.ModuleName}, {Account: pooltypes.StreamAccount}, + {Account: pooltypes.ProtocolPoolDistrAccount}, {Account: minttypes.ModuleName, Permissions: []string{authtypes.Minter}}, {Account: stakingtypes.BondedPoolName, Permissions: []string{authtypes.Burner, stakingtypes.ModuleName}}, {Account: stakingtypes.NotBondedPoolName, Permissions: []string{authtypes.Burner, stakingtypes.ModuleName}}, @@ -119,6 +120,7 @@ var ( BeginBlockers: []string{ minttypes.ModuleName, distrtypes.ModuleName, + pooltypes.ModuleName, slashingtypes.ModuleName, evidencetypes.ModuleName, stakingtypes.ModuleName, diff --git a/simapp/v2/app_config.go b/simapp/v2/app_config.go index aff5f923093c..c3e5e0492935 100644 --- a/simapp/v2/app_config.go +++ b/simapp/v2/app_config.go @@ -77,6 +77,7 @@ var ( {Account: distrtypes.ModuleName}, {Account: pooltypes.ModuleName}, {Account: pooltypes.StreamAccount}, + {Account: pooltypes.ProtocolPoolDistrAccount}, {Account: minttypes.ModuleName, Permissions: []string{authtypes.Minter}}, {Account: stakingtypes.BondedPoolName, Permissions: []string{authtypes.Burner, stakingtypes.ModuleName}}, {Account: stakingtypes.NotBondedPoolName, Permissions: []string{authtypes.Burner, stakingtypes.ModuleName}}, @@ -115,6 +116,7 @@ var ( BeginBlockers: []string{ minttypes.ModuleName, distrtypes.ModuleName, + pooltypes.ModuleName, slashingtypes.ModuleName, evidencetypes.ModuleName, stakingtypes.ModuleName, diff --git a/tests/integration/distribution/keeper/msg_server_test.go b/tests/integration/distribution/keeper/msg_server_test.go index f8dc17862403..9a85cac995e0 100644 --- a/tests/integration/distribution/keeper/msg_server_test.go +++ b/tests/integration/distribution/keeper/msg_server_test.go @@ -86,11 +86,12 @@ func initFixture(t *testing.T) *fixture { authority := authtypes.NewModuleAddress("gov") maccPerms := map[string][]string{ - pooltypes.ModuleName: {}, - pooltypes.StreamAccount: {}, - distrtypes.ModuleName: {authtypes.Minter}, - stakingtypes.BondedPoolName: {authtypes.Burner, authtypes.Staking}, - stakingtypes.NotBondedPoolName: {authtypes.Burner, authtypes.Staking}, + pooltypes.ModuleName: {}, + pooltypes.StreamAccount: {}, + pooltypes.ProtocolPoolDistrAccount: {}, + distrtypes.ModuleName: {authtypes.Minter}, + stakingtypes.BondedPoolName: {authtypes.Burner, authtypes.Staking}, + stakingtypes.NotBondedPoolName: {authtypes.Burner, authtypes.Staking}, } // gomock initializations @@ -137,13 +138,13 @@ func initFixture(t *testing.T) *fixture { poolKeeper := poolkeeper.NewKeeper(cdc, runtime.NewEnvironment(runtime.NewKVStoreService(keys[pooltypes.StoreKey]), log.NewNopLogger()), accountKeeper, bankKeeper, stakingKeeper, authority.String()) distrKeeper := distrkeeper.NewKeeper( - cdc, runtime.NewEnvironment(runtime.NewKVStoreService(keys[distrtypes.StoreKey]), logger), accountKeeper, bankKeeper, stakingKeeper, poolKeeper, cometService, distrtypes.ModuleName, authority.String(), + cdc, runtime.NewEnvironment(runtime.NewKVStoreService(keys[distrtypes.StoreKey]), logger), accountKeeper, bankKeeper, stakingKeeper, cometService, distrtypes.ModuleName, authority.String(), ) authModule := auth.NewAppModule(cdc, accountKeeper, acctsModKeeper, authsims.RandomGenesisAccounts) bankModule := bank.NewAppModule(cdc, bankKeeper, accountKeeper) stakingModule := staking.NewAppModule(cdc, stakingKeeper, accountKeeper, bankKeeper) - distrModule := distribution.NewAppModule(cdc, distrKeeper, accountKeeper, bankKeeper, stakingKeeper, poolKeeper) + distrModule := distribution.NewAppModule(cdc, distrKeeper, accountKeeper, bankKeeper, stakingKeeper) poolModule := protocolpool.NewAppModule(cdc, poolKeeper, accountKeeper, bankKeeper) addr := sdk.AccAddress(PKS[0].Address()) diff --git a/tests/integration/gov/keeper/keeper_test.go b/tests/integration/gov/keeper/keeper_test.go index d98e86c06dd0..bb2f58979edf 100644 --- a/tests/integration/gov/keeper/keeper_test.go +++ b/tests/integration/gov/keeper/keeper_test.go @@ -67,12 +67,13 @@ func initFixture(tb testing.TB) *fixture { authority := authtypes.NewModuleAddress(types.ModuleName) maccPerms := map[string][]string{ - pooltypes.ModuleName: {}, - pooltypes.StreamAccount: {}, - minttypes.ModuleName: {authtypes.Minter}, - stakingtypes.BondedPoolName: {authtypes.Burner, authtypes.Staking}, - stakingtypes.NotBondedPoolName: {authtypes.Burner, authtypes.Staking}, - types.ModuleName: {authtypes.Burner}, + pooltypes.ModuleName: {}, + pooltypes.StreamAccount: {}, + pooltypes.ProtocolPoolDistrAccount: {}, + minttypes.ModuleName: {authtypes.Minter}, + stakingtypes.BondedPoolName: {authtypes.Burner, authtypes.Staking}, + stakingtypes.NotBondedPoolName: {authtypes.Burner, authtypes.Staking}, + types.ModuleName: {authtypes.Burner}, } // gomock initializations diff --git a/tests/integration/protocolpool/module_test.go b/tests/integration/protocolpool/module_test.go index 2c527dd0d52d..b8148be37106 100644 --- a/tests/integration/protocolpool/module_test.go +++ b/tests/integration/protocolpool/module_test.go @@ -87,7 +87,6 @@ func TestWithdrawAnytime(t *testing.T) { // TestExpireInTheMiddle tests if a continuous fund that expires without anyone // calling the withdraw function, the funds are still distributed correctly. func TestExpireInTheMiddle(t *testing.T) { - t.Skip("This is a bug @facu found, will fix in another PR") var accountKeeper authkeeper.AccountKeeper var protocolpoolKeeper protocolpoolkeeper.Keeper var bankKeeper bankkeeper.Keeper @@ -131,8 +130,8 @@ func TestExpireInTheMiddle(t *testing.T) { _, err = msgServer.WithdrawContinuousFund(ctx, &protocolpooltypes.MsgWithdrawContinuousFund{ RecipientAddress: testAddr0Str, }) - require.Error(t, err) + require.NoError(t, err) endBalance := bankKeeper.GetBalance(ctx, testAddrs[0], sdk.DefaultBondDenom) - require.Equal(t, "158441stake", endBalance.String()) + require.Equal(t, "237661stake", endBalance.String()) } diff --git a/testutil/configurator/configurator.go b/testutil/configurator/configurator.go index 84e1fc986c45..91c93ba2d5b0 100644 --- a/testutil/configurator/configurator.go +++ b/testutil/configurator/configurator.go @@ -50,6 +50,7 @@ func defaultConfig() *Config { BeginBlockersOrder: []string{ testutil.MintModuleName, testutil.DistributionModuleName, + testutil.ProtocolPoolModuleName, testutil.SlashingModuleName, testutil.EvidenceModuleName, testutil.StakingModuleName, @@ -164,6 +165,7 @@ func AuthModule() ModuleOption { {Account: testutil.NFTModuleName}, {Account: testutil.ProtocolPoolModuleName}, {Account: "stream_acc"}, + {Account: "protocolpool_distr"}, }, }), } diff --git a/x/distribution/CHANGELOG.md b/x/distribution/CHANGELOG.md index 86940a5e2d81..0a341876bc94 100644 --- a/x/distribution/CHANGELOG.md +++ b/x/distribution/CHANGELOG.md @@ -29,9 +29,13 @@ Ref: https://keepachangelog.com/en/1.0.0/ * -### API Breaking Changes +### Improvements +* [#20790](https://github.com/cosmos/cosmos-sdk/pull/20790) `x/distribution` does not depend on `x/protocolpool` anymore, now `x/distribution` only does token transfers and `x/protocolpool` does the rest. + +### API Breaking Changes +* [#20790](https://github.com/cosmos/cosmos-sdk/pull/20790) `x/distribution` does not depend on `x/protocolpool` anymore, meaning NewAppModule and NewKeeper do not take it as an argument. * [#20588](https://github.com/cosmos/cosmos-sdk/pull/20588) `x/distribution` now takes cometService in order to get consensus related information. * [#19868](https://github.com/cosmos/cosmos-sdk/pull/19868) Removes Accounts String method * `NewMsgSetWithdrawAddress` now takes strings as argument instead of `sdk.AccAddress`. @@ -52,7 +56,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ * remove `Keeper`: `SetDelegatorWithdrawAddr`, `DeleteDelegatorWithdrawAddr`, `IterateDelegatorWithdrawAddrs`. * [#16459](https://github.com/cosmos/cosmos-sdk/pull/16459) use collections for `ValidatorCurrentRewards` state management: * remove `Keeper`: `IterateValidatorCurrentRewards`, `GetValidatorCurrentRewards`, `SetValidatorCurrentRewards`, `DeleteValidatorCurrentRewards` -* [#17657](https://github.com/cosmos/cosmos-sdk/pull/17657) The distribution module keeper now takes a new argument `PoolKeeper` in addition. +* [#17657](https://github.com/cosmos/cosmos-sdk/pull/17657) ~The distribution module keeper now takes a new argument `PoolKeeper` in addition.~ Reverted on #20790 * [#17670](https://github.com/cosmos/cosmos-sdk/pull/17670) `AllocateTokens` takes `comet.VoteInfos` instead of `[]abci.VoteInfo` * [#19740](https://github.com/cosmos/cosmos-sdk/pull/19740) `InitGenesis` and `ExportGenesis` module code and keeper code do not panic but return errors. diff --git a/x/distribution/depinject.go b/x/distribution/depinject.go index ddd6c64b33b3..07e63548efac 100644 --- a/x/distribution/depinject.go +++ b/x/distribution/depinject.go @@ -36,7 +36,6 @@ type ModuleInputs struct { AccountKeeper types.AccountKeeper BankKeeper types.BankKeeper StakingKeeper types.StakingKeeper - PoolKeeper types.PoolKeeper } type ModuleOutputs struct { @@ -70,13 +69,12 @@ func ProvideModule(in ModuleInputs) ModuleOutputs { in.AccountKeeper, in.BankKeeper, in.StakingKeeper, - in.PoolKeeper, in.CometService, feeCollectorName, authorityAddr, ) - m := NewAppModule(in.Cdc, k, in.AccountKeeper, in.BankKeeper, in.StakingKeeper, in.PoolKeeper) + m := NewAppModule(in.Cdc, k, in.AccountKeeper, in.BankKeeper, in.StakingKeeper) return ModuleOutputs{ DistrKeeper: k, diff --git a/x/distribution/go.mod b/x/distribution/go.mod index a429835f472d..420cfda6f638 100644 --- a/x/distribution/go.mod +++ b/x/distribution/go.mod @@ -187,6 +187,7 @@ replace ( cosmossdk.io/x/auth => ../auth cosmossdk.io/x/bank => ../bank cosmossdk.io/x/consensus => ../consensus + cosmossdk.io/x/protocolpool => ../protocolpool cosmossdk.io/x/staking => ../staking cosmossdk.io/x/tx => ../tx ) diff --git a/x/distribution/go.sum b/x/distribution/go.sum index 58a04eb3afea..4879cfa34550 100644 --- a/x/distribution/go.sum +++ b/x/distribution/go.sum @@ -14,8 +14,6 @@ cosmossdk.io/schema v0.1.1 h1:I0M6pgI7R10nq+/HCQfbO6BsGBZA8sQy+duR1Y3aKcA= cosmossdk.io/schema v0.1.1/go.mod h1:RDAhxIeNB4bYqAlF4NBJwRrgtnciMcyyg0DOKnhNZQQ= cosmossdk.io/store v1.1.1-0.20240418092142-896cdf1971bc h1:R9O9d75e0qZYUsVV0zzi+D7cNLnX2JrUOQNoIPaF0Bg= cosmossdk.io/store v1.1.1-0.20240418092142-896cdf1971bc/go.mod h1:amTTatOUV3u1PsKmNb87z6/galCxrRbz9kRdJkL0DyU= -cosmossdk.io/x/protocolpool v0.0.0-20230925135524-a1bc045b3190 h1:XQJj9Dv9Gtze0l2TF79BU5lkP6MkUveTUuKICmxoz+o= -cosmossdk.io/x/protocolpool v0.0.0-20230925135524-a1bc045b3190/go.mod h1:7WUGupOvmlHJoIMBz1JbObQxeo6/TDiuDBxmtod8HRg= filippo.io/edwards25519 v1.1.0 h1:FNf4tywRC1HmFuKW5xopWpigGjJKiJSV0Cqo0cJWDaA= filippo.io/edwards25519 v1.1.0/go.mod h1:BxyFTGdWcka3PhytdK4V28tE5sGfRvvvRV7EaN4VDT4= github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 h1:/vQbFIOMbk2FiG/kXiLl8BRyzTWDw7gX/Hz7Dd5eDMs= diff --git a/x/distribution/keeper/allocation.go b/x/distribution/keeper/allocation.go index 992c487ddb46..123b161c0b58 100644 --- a/x/distribution/keeper/allocation.go +++ b/x/distribution/keeper/allocation.go @@ -79,12 +79,7 @@ func (k Keeper) AllocateTokens(ctx context.Context, totalPreviousPower int64, bo } // send to community pool and set remainder in fee pool amt, re := remaining.TruncateDecimal() - if err := k.bankKeeper.SendCoinsFromModuleToModule(ctx, types.ModuleName, types.ProtocolPoolModuleName, amt); err != nil { - return err - } - - // set ToDistribute in protocolpool to keep track of continuous funds distribution - if err := k.poolKeeper.SetToDistribute(ctx, amt, k.GetAuthority()); err != nil { // TODO: this should be distribution module account + if err := k.bankKeeper.SendCoinsFromModuleToModule(ctx, types.ModuleName, types.ProtocolPoolDistrAccount, amt); err != nil { return err } @@ -170,7 +165,7 @@ func (k Keeper) sendDecimalPoolToCommunityPool(ctx context.Context) error { } amt, re := feePool.DecimalPool.TruncateDecimal() - if err := k.bankKeeper.SendCoinsFromModuleToModule(ctx, types.ModuleName, types.ProtocolPoolModuleName, amt); err != nil { + if err := k.bankKeeper.SendCoinsFromModuleToModule(ctx, types.ModuleName, types.ProtocolPoolDistrAccount, amt); err != nil { return err } diff --git a/x/distribution/keeper/allocation_test.go b/x/distribution/keeper/allocation_test.go index b76b3409fbc9..f319ad456cbe 100644 --- a/x/distribution/keeper/allocation_test.go +++ b/x/distribution/keeper/allocation_test.go @@ -51,7 +51,6 @@ func TestAllocateTokensToValidatorWithCommission(t *testing.T) { bankKeeper := distrtestutil.NewMockBankKeeper(ctrl) stakingKeeper := distrtestutil.NewMockStakingKeeper(ctrl) accountKeeper := distrtestutil.NewMockAccountKeeper(ctrl) - poolKeeper := distrtestutil.NewMockPoolKeeper(ctrl) env := runtime.NewEnvironment(runtime.NewKVStoreService(key), coretesting.NewNopLogger()) @@ -69,7 +68,6 @@ func TestAllocateTokensToValidatorWithCommission(t *testing.T) { accountKeeper, bankKeeper, stakingKeeper, - poolKeeper, testCometService, "fee_collector", authorityAddr, @@ -118,7 +116,6 @@ func TestAllocateTokensToManyValidators(t *testing.T) { bankKeeper := distrtestutil.NewMockBankKeeper(ctrl) stakingKeeper := distrtestutil.NewMockStakingKeeper(ctrl) accountKeeper := distrtestutil.NewMockAccountKeeper(ctrl) - poolKeeper := distrtestutil.NewMockPoolKeeper(ctrl) feeCollectorAcc := authtypes.NewEmptyModuleAccount("fee_collector") accountKeeper.EXPECT().GetModuleAddress("distribution").Return(distrAcc.GetAddress()) @@ -136,7 +133,6 @@ func TestAllocateTokensToManyValidators(t *testing.T) { accountKeeper, bankKeeper, stakingKeeper, - poolKeeper, testCometService, "fee_collector", authorityAddr, @@ -200,8 +196,7 @@ func TestAllocateTokensToManyValidators(t *testing.T) { fees := sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, math.NewInt(100))) bankKeeper.EXPECT().GetAllBalances(gomock.Any(), feeCollectorAcc.GetAddress()).Return(fees) bankKeeper.EXPECT().SendCoinsFromModuleToModule(gomock.Any(), "fee_collector", disttypes.ModuleName, fees) - bankKeeper.EXPECT().SendCoinsFromModuleToModule(gomock.Any(), disttypes.ModuleName, disttypes.ProtocolPoolModuleName, sdk.Coins{{Denom: sdk.DefaultBondDenom, Amount: math.NewInt(2)}}) // 2 community pool coins - poolKeeper.EXPECT().SetToDistribute(ctx, gomock.Any(), gomock.Any()) + bankKeeper.EXPECT().SendCoinsFromModuleToModule(gomock.Any(), disttypes.ModuleName, disttypes.ProtocolPoolDistrAccount, sdk.Coins{{Denom: sdk.DefaultBondDenom, Amount: math.NewInt(2)}}) // 2 community pool coins votes := []comet.VoteInfo{ { @@ -259,7 +254,6 @@ func TestAllocateTokensTruncation(t *testing.T) { bankKeeper := distrtestutil.NewMockBankKeeper(ctrl) stakingKeeper := distrtestutil.NewMockStakingKeeper(ctrl) accountKeeper := distrtestutil.NewMockAccountKeeper(ctrl) - poolKeeper := distrtestutil.NewMockPoolKeeper(ctrl) feeCollectorAcc := authtypes.NewEmptyModuleAccount("fee_collector") accountKeeper.EXPECT().GetModuleAddress("distribution").Return(distrAcc.GetAddress()) @@ -277,7 +271,6 @@ func TestAllocateTokensTruncation(t *testing.T) { accountKeeper, bankKeeper, stakingKeeper, - poolKeeper, testCometService, "fee_collector", authorityAddr, @@ -354,8 +347,7 @@ func TestAllocateTokensTruncation(t *testing.T) { fees := sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, math.NewInt(634195840))) bankKeeper.EXPECT().GetAllBalances(gomock.Any(), feeCollectorAcc.GetAddress()).Return(fees) bankKeeper.EXPECT().SendCoinsFromModuleToModule(gomock.Any(), "fee_collector", disttypes.ModuleName, fees) - bankKeeper.EXPECT().SendCoinsFromModuleToModule(gomock.Any(), disttypes.ModuleName, disttypes.ProtocolPoolModuleName, gomock.Any()) // something is sent to community pool - poolKeeper.EXPECT().SetToDistribute(ctx, gomock.Any(), gomock.Any()) + bankKeeper.EXPECT().SendCoinsFromModuleToModule(gomock.Any(), disttypes.ModuleName, disttypes.ProtocolPoolDistrAccount, gomock.Any()) // something is sent to community pool votes := []comet.VoteInfo{ { diff --git a/x/distribution/keeper/delegation_test.go b/x/distribution/keeper/delegation_test.go index 76bcfb628787..31419b10e082 100644 --- a/x/distribution/keeper/delegation_test.go +++ b/x/distribution/keeper/delegation_test.go @@ -36,7 +36,6 @@ func TestCalculateRewardsBasic(t *testing.T) { bankKeeper := distrtestutil.NewMockBankKeeper(ctrl) stakingKeeper := distrtestutil.NewMockStakingKeeper(ctrl) accountKeeper := distrtestutil.NewMockAccountKeeper(ctrl) - poolKeeper := distrtestutil.NewMockPoolKeeper(ctrl) accountKeeper.EXPECT().GetModuleAddress("distribution").Return(distrAcc.GetAddress()) stakingKeeper.EXPECT().ValidatorAddressCodec().Return(address.NewBech32Codec(sdk.Bech32PrefixValAddr)).AnyTimes() @@ -53,7 +52,6 @@ func TestCalculateRewardsBasic(t *testing.T) { accountKeeper, bankKeeper, stakingKeeper, - poolKeeper, testCometService, "fee_collector", authorityAddr, @@ -150,7 +148,6 @@ func TestCalculateRewardsAfterSlash(t *testing.T) { bankKeeper := distrtestutil.NewMockBankKeeper(ctrl) stakingKeeper := distrtestutil.NewMockStakingKeeper(ctrl) accountKeeper := distrtestutil.NewMockAccountKeeper(ctrl) - poolKeeper := distrtestutil.NewMockPoolKeeper(ctrl) accountKeeper.EXPECT().GetModuleAddress("distribution").Return(distrAcc.GetAddress()) stakingKeeper.EXPECT().ValidatorAddressCodec().Return(address.NewBech32Codec(sdk.Bech32PrefixValAddr)).AnyTimes() @@ -167,7 +164,6 @@ func TestCalculateRewardsAfterSlash(t *testing.T) { accountKeeper, bankKeeper, stakingKeeper, - poolKeeper, testCometService, "fee_collector", authorityAddr, @@ -267,7 +263,6 @@ func TestCalculateRewardsAfterManySlashes(t *testing.T) { bankKeeper := distrtestutil.NewMockBankKeeper(ctrl) stakingKeeper := distrtestutil.NewMockStakingKeeper(ctrl) accountKeeper := distrtestutil.NewMockAccountKeeper(ctrl) - poolKeeper := distrtestutil.NewMockPoolKeeper(ctrl) accountKeeper.EXPECT().GetModuleAddress("distribution").Return(distrAcc.GetAddress()) stakingKeeper.EXPECT().ValidatorAddressCodec().Return(address.NewBech32Codec(sdk.Bech32PrefixValAddr)).AnyTimes() @@ -284,7 +279,6 @@ func TestCalculateRewardsAfterManySlashes(t *testing.T) { accountKeeper, bankKeeper, stakingKeeper, - poolKeeper, testCometService, "fee_collector", authorityAddr, @@ -405,7 +399,6 @@ func TestCalculateRewardsMultiDelegator(t *testing.T) { bankKeeper := distrtestutil.NewMockBankKeeper(ctrl) stakingKeeper := distrtestutil.NewMockStakingKeeper(ctrl) accountKeeper := distrtestutil.NewMockAccountKeeper(ctrl) - poolKeeper := distrtestutil.NewMockPoolKeeper(ctrl) accountKeeper.EXPECT().GetModuleAddress("distribution").Return(distrAcc.GetAddress()) stakingKeeper.EXPECT().ValidatorAddressCodec().Return(address.NewBech32Codec(sdk.Bech32PrefixValAddr)).AnyTimes() @@ -422,7 +415,6 @@ func TestCalculateRewardsMultiDelegator(t *testing.T) { accountKeeper, bankKeeper, stakingKeeper, - poolKeeper, testCometService, "fee_collector", authorityAddr, @@ -516,7 +508,6 @@ func TestWithdrawDelegationRewardsBasic(t *testing.T) { bankKeeper := distrtestutil.NewMockBankKeeper(ctrl) stakingKeeper := distrtestutil.NewMockStakingKeeper(ctrl) accountKeeper := distrtestutil.NewMockAccountKeeper(ctrl) - poolKeeper := distrtestutil.NewMockPoolKeeper(ctrl) accountKeeper.EXPECT().GetModuleAddress("distribution").Return(distrAcc.GetAddress()) stakingKeeper.EXPECT().ValidatorAddressCodec().Return(address.NewBech32Codec(sdk.Bech32PrefixValAddr)).AnyTimes() @@ -533,7 +524,6 @@ func TestWithdrawDelegationRewardsBasic(t *testing.T) { accountKeeper, bankKeeper, stakingKeeper, - poolKeeper, testCometService, "fee_collector", authorityAddr, @@ -605,7 +595,6 @@ func TestCalculateRewardsAfterManySlashesInSameBlock(t *testing.T) { bankKeeper := distrtestutil.NewMockBankKeeper(ctrl) stakingKeeper := distrtestutil.NewMockStakingKeeper(ctrl) accountKeeper := distrtestutil.NewMockAccountKeeper(ctrl) - poolKeeper := distrtestutil.NewMockPoolKeeper(ctrl) accountKeeper.EXPECT().GetModuleAddress("distribution").Return(distrAcc.GetAddress()) stakingKeeper.EXPECT().ValidatorAddressCodec().Return(address.NewBech32Codec(sdk.Bech32PrefixValAddr)).AnyTimes() @@ -622,7 +611,6 @@ func TestCalculateRewardsAfterManySlashesInSameBlock(t *testing.T) { accountKeeper, bankKeeper, stakingKeeper, - poolKeeper, testCometService, "fee_collector", authorityAddr, @@ -735,7 +723,6 @@ func TestCalculateRewardsMultiDelegatorMultiSlash(t *testing.T) { bankKeeper := distrtestutil.NewMockBankKeeper(ctrl) stakingKeeper := distrtestutil.NewMockStakingKeeper(ctrl) accountKeeper := distrtestutil.NewMockAccountKeeper(ctrl) - poolKeeper := distrtestutil.NewMockPoolKeeper(ctrl) accountKeeper.EXPECT().GetModuleAddress("distribution").Return(distrAcc.GetAddress()) stakingKeeper.EXPECT().ValidatorAddressCodec().Return(address.NewBech32Codec(sdk.Bech32PrefixValAddr)).AnyTimes() @@ -752,7 +739,6 @@ func TestCalculateRewardsMultiDelegatorMultiSlash(t *testing.T) { accountKeeper, bankKeeper, stakingKeeper, - poolKeeper, testCometService, "fee_collector", authorityAddr, @@ -889,7 +875,6 @@ func TestCalculateRewardsMultiDelegatorMultWithdraw(t *testing.T) { bankKeeper := distrtestutil.NewMockBankKeeper(ctrl) stakingKeeper := distrtestutil.NewMockStakingKeeper(ctrl) accountKeeper := distrtestutil.NewMockAccountKeeper(ctrl) - poolKeeper := distrtestutil.NewMockPoolKeeper(ctrl) accountKeeper.EXPECT().GetModuleAddress("distribution").Return(distrAcc.GetAddress()) stakingKeeper.EXPECT().ValidatorAddressCodec().Return(address.NewBech32Codec(sdk.Bech32PrefixValAddr)).AnyTimes() @@ -906,7 +891,6 @@ func TestCalculateRewardsMultiDelegatorMultWithdraw(t *testing.T) { accountKeeper, bankKeeper, stakingKeeper, - poolKeeper, testCometService, "fee_collector", authorityAddr, @@ -1103,7 +1087,6 @@ func Test100PercentCommissionReward(t *testing.T) { bankKeeper := distrtestutil.NewMockBankKeeper(ctrl) stakingKeeper := distrtestutil.NewMockStakingKeeper(ctrl) accountKeeper := distrtestutil.NewMockAccountKeeper(ctrl) - poolKeeper := distrtestutil.NewMockPoolKeeper(ctrl) accountKeeper.EXPECT().GetModuleAddress("distribution").Return(distrAcc.GetAddress()) stakingKeeper.EXPECT().ValidatorAddressCodec().Return(address.NewBech32Codec(sdk.Bech32PrefixValAddr)).AnyTimes() @@ -1121,7 +1104,6 @@ func Test100PercentCommissionReward(t *testing.T) { accountKeeper, bankKeeper, stakingKeeper, - poolKeeper, testCometService, "fee_collector", authorityAddr, diff --git a/x/distribution/keeper/grpc_query.go b/x/distribution/keeper/grpc_query.go index 62b602c8a805..de8657276fbe 100644 --- a/x/distribution/keeper/grpc_query.go +++ b/x/distribution/keeper/grpc_query.go @@ -373,9 +373,12 @@ func (k Querier) DelegatorWithdrawAddress(ctx context.Context, req *types.QueryD // This method uses deprecated query request. Use CommunityPool from x/protocolpool module instead. // CommunityPool queries the community pool coins func (k Querier) CommunityPool(ctx context.Context, req *types.QueryCommunityPoolRequest) (*types.QueryCommunityPoolResponse, error) { - pool, err := k.poolKeeper.GetCommunityPool(ctx) - if err != nil { - return nil, err + moduleAccount := k.authKeeper.GetModuleAccount(ctx, types.ProtocolPoolModuleName) + if moduleAccount == nil { + return nil, status.Error(codes.Internal, "protocolpool module account does not exist") } - return &types.QueryCommunityPoolResponse{Pool: sdk.NewDecCoinsFromCoins(pool...)}, nil + + balances := k.bankKeeper.GetAllBalances(ctx, moduleAccount.GetAddress()) + + return &types.QueryCommunityPoolResponse{Pool: sdk.NewDecCoinsFromCoins(balances...)}, nil } diff --git a/x/distribution/keeper/grpc_query_test.go b/x/distribution/keeper/grpc_query_test.go index 14bbbd66902f..affc16b392b1 100644 --- a/x/distribution/keeper/grpc_query_test.go +++ b/x/distribution/keeper/grpc_query_test.go @@ -7,6 +7,7 @@ import ( "github.com/stretchr/testify/require" "cosmossdk.io/math" + authtypes "cosmossdk.io/x/auth/types" "cosmossdk.io/x/distribution/keeper" distrtestutil "cosmossdk.io/x/distribution/testutil" "cosmossdk.io/x/distribution/types" @@ -147,9 +148,13 @@ func TestQueryCommunityPool(t *testing.T) { ctx, _, distrKeeper, dep := initFixture(t) queryServer := keeper.NewQuerier(distrKeeper) + poolAcc := authtypes.NewEmptyModuleAccount(types.ProtocolPoolModuleName) + dep.accountKeeper.EXPECT().GetModuleAccount(gomock.Any(), types.ProtocolPoolModuleName).Return(poolAcc).AnyTimes() + + dep.bankKeeper.EXPECT().GetAllBalances(gomock.Any(), poolAcc.GetAddress()).Return(sdk.NewCoins(sdk.NewCoin("stake", math.NewInt(100)))) + coins := sdk.NewCoins(sdk.NewCoin("stake", math.NewInt(100))) decCoins := sdk.NewDecCoinsFromCoins(coins...) - dep.poolKeeper.EXPECT().GetCommunityPool(gomock.Any()).Return(coins, nil).AnyTimes() cases := []struct { name string diff --git a/x/distribution/keeper/keeper.go b/x/distribution/keeper/keeper.go index bc5096c4c506..0c3238353eba 100644 --- a/x/distribution/keeper/keeper.go +++ b/x/distribution/keeper/keeper.go @@ -28,7 +28,6 @@ type Keeper struct { authKeeper types.AccountKeeper bankKeeper types.BankKeeper stakingKeeper types.StakingKeeper - poolKeeper types.PoolKeeper // the address capable of executing a MsgUpdateParams message. Typically, this // should be the x/gov module account. @@ -64,7 +63,6 @@ func NewKeeper( ak types.AccountKeeper, bk types.BankKeeper, sk types.StakingKeeper, - pk types.PoolKeeper, cometService comet.Service, feeCollectorName, authority string, ) Keeper { @@ -81,7 +79,6 @@ func NewKeeper( authKeeper: ak, bankKeeper: bk, stakingKeeper: sk, - poolKeeper: pk, feeCollectorName: feeCollectorName, authority: authority, Params: collections.NewItem(sb, types.ParamsKey, "params", codec.CollValue[types.Params](cdc)), diff --git a/x/distribution/keeper/keeper_test.go b/x/distribution/keeper/keeper_test.go index 8b6afcebd9ce..a3fdb44d797c 100644 --- a/x/distribution/keeper/keeper_test.go +++ b/x/distribution/keeper/keeper_test.go @@ -30,7 +30,6 @@ type dep struct { bankKeeper *distrtestutil.MockBankKeeper stakingKeeper *distrtestutil.MockStakingKeeper accountKeeper *distrtestutil.MockAccountKeeper - poolKeeper *distrtestutil.MockPoolKeeper } func initFixture(t *testing.T) (sdk.Context, []sdk.AccAddress, keeper.Keeper, dep) { @@ -47,7 +46,6 @@ func initFixture(t *testing.T) (sdk.Context, []sdk.AccAddress, keeper.Keeper, de bankKeeper := distrtestutil.NewMockBankKeeper(ctrl) stakingKeeper := distrtestutil.NewMockStakingKeeper(ctrl) accountKeeper := distrtestutil.NewMockAccountKeeper(ctrl) - poolKeeper := distrtestutil.NewMockPoolKeeper(ctrl) accountKeeper.EXPECT().GetModuleAddress("distribution").Return(distrAcc.GetAddress()) accountKeeper.EXPECT().AddressCodec().Return(address.NewBech32Codec("cosmos")).AnyTimes() @@ -69,7 +67,6 @@ func initFixture(t *testing.T) (sdk.Context, []sdk.AccAddress, keeper.Keeper, de accountKeeper, bankKeeper, stakingKeeper, - poolKeeper, testCometService, "fee_collector", authorityAddr, @@ -78,7 +75,7 @@ func initFixture(t *testing.T) (sdk.Context, []sdk.AccAddress, keeper.Keeper, de params := types.DefaultParams() require.NoError(t, distrKeeper.Params.Set(ctx, params)) - return ctx, addrs, distrKeeper, dep{bankKeeper, stakingKeeper, accountKeeper, poolKeeper} + return ctx, addrs, distrKeeper, dep{bankKeeper, stakingKeeper, accountKeeper} } func TestSetWithdrawAddr(t *testing.T) { diff --git a/x/distribution/keeper/migrations.go b/x/distribution/keeper/migrations.go index cb6be65cb6b2..7a35fa76f893 100644 --- a/x/distribution/keeper/migrations.go +++ b/x/distribution/keeper/migrations.go @@ -42,7 +42,7 @@ func (m Migrator) Migrate3to4(ctx context.Context) error { func (m Migrator) migrateFunds(ctx context.Context) error { macc := m.keeper.GetDistributionAccount(ctx) - poolMacc := m.keeper.authKeeper.GetModuleAccount(ctx, types.ProtocolPoolModuleName) + poolMacc := m.keeper.authKeeper.GetModuleAccount(ctx, types.ProtocolPoolDistrAccount) feePool, err := m.keeper.FeePool.Get(ctx) if err != nil { diff --git a/x/distribution/keeper/msg_server.go b/x/distribution/keeper/msg_server.go index 6f8b622f52b3..2b405f9b053a 100644 --- a/x/distribution/keeper/msg_server.go +++ b/x/distribution/keeper/msg_server.go @@ -114,7 +114,7 @@ func (k msgServer) FundCommunityPool(ctx context.Context, msg *types.MsgFundComm return nil, err } - if err := k.poolKeeper.FundCommunityPool(ctx, msg.Amount, depositor); err != nil { + if err := k.bankKeeper.SendCoinsFromAccountToModule(ctx, depositor, types.ProtocolPoolModuleName, msg.Amount); err != nil { return nil, err } @@ -158,7 +158,7 @@ func (k msgServer) CommunityPoolSpend(ctx context.Context, msg *types.MsgCommuni return nil, fmt.Errorf("invalid recipient address: %w", err) } - if err := k.poolKeeper.DistributeFromCommunityPool(ctx, msg.Amount, recipient); err != nil { + if err := k.bankKeeper.SendCoinsFromModuleToAccount(ctx, types.ProtocolPoolModuleName, recipient, msg.Amount); err != nil { return nil, err } diff --git a/x/distribution/keeper/msg_server_test.go b/x/distribution/keeper/msg_server_test.go index 8c5cad6d39ac..59a21395de4c 100644 --- a/x/distribution/keeper/msg_server_test.go +++ b/x/distribution/keeper/msg_server_test.go @@ -176,12 +176,13 @@ func TestMsgWithdrawValidatorCommission(t *testing.T) { func TestMsgFundCommunityPool(t *testing.T) { ctx, addrs, distrKeeper, dep := initFixture(t) - dep.poolKeeper.EXPECT().FundCommunityPool(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil).AnyTimes() msgServer := keeper.NewMsgServerImpl(distrKeeper) addr0Str, err := codectestutil.CodecOptions{}.GetAddressCodec().BytesToString(addrs[0]) require.NoError(t, err) + dep.bankKeeper.EXPECT().SendCoinsFromAccountToModule(gomock.Any(), addrs[0], types.ProtocolPoolModuleName, sdk.NewCoins(sdk.NewCoin("stake", math.NewInt(1000)))).Return(nil) + cases := []struct { name string msg *types.MsgFundCommunityPool //nolint:staticcheck // Testing deprecated method @@ -281,7 +282,6 @@ func TestMsgUpdateParams(t *testing.T) { func TestMsgCommunityPoolSpend(t *testing.T) { ctx, addrs, distrKeeper, dep := initFixture(t) - dep.poolKeeper.EXPECT().DistributeFromCommunityPool(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil).AnyTimes() msgServer := keeper.NewMsgServerImpl(distrKeeper) authorityAddr, err := codectestutil.CodecOptions{}.GetAddressCodec().BytesToString(authtypes.NewModuleAddress("gov")) @@ -289,6 +289,8 @@ func TestMsgCommunityPoolSpend(t *testing.T) { addr0Str, err := codectestutil.CodecOptions{}.GetAddressCodec().BytesToString(addrs[0]) require.NoError(t, err) + dep.bankKeeper.EXPECT().SendCoinsFromModuleToAccount(gomock.Any(), types.ProtocolPoolModuleName, addrs[0], sdk.NewCoins(sdk.NewCoin("stake", math.NewInt(1000)))).Return(nil) + cases := []struct { name string msg *types.MsgCommunityPoolSpend //nolint:staticcheck // Testing deprecated method diff --git a/x/distribution/migrations/v4/migrate_funds_test.go b/x/distribution/migrations/v4/migrate_funds_test.go index e801040009a2..90f557e130c3 100644 --- a/x/distribution/migrations/v4/migrate_funds_test.go +++ b/x/distribution/migrations/v4/migrate_funds_test.go @@ -60,7 +60,6 @@ func TestFundsMigration(t *testing.T) { ctrl := gomock.NewController(t) acctsModKeeper := authtestutil.NewMockAccountsModKeeper(ctrl) stakingKeeper := distrtestutil.NewMockStakingKeeper(ctrl) - poolKeeper := distrtestutil.NewMockPoolKeeper(ctrl) accNum := uint64(0) acctsModKeeper.EXPECT().NextAccountNumber(gomock.Any()).AnyTimes().DoAndReturn(func(ctx context.Context) (uint64, error) { @@ -97,7 +96,6 @@ func TestFundsMigration(t *testing.T) { accountKeeper, bankKeeper, stakingKeeper, - poolKeeper, &emptyCometService{}, disttypes.ModuleName, authority, diff --git a/x/distribution/module.go b/x/distribution/module.go index bd0d3c6d3c89..82e991069335 100644 --- a/x/distribution/module.go +++ b/x/distribution/module.go @@ -48,13 +48,12 @@ type AppModule struct { accountKeeper types.AccountKeeper bankKeeper types.BankKeeper stakingKeeper types.StakingKeeper - poolKeeper types.PoolKeeper } // NewAppModule creates a new AppModule object func NewAppModule( cdc codec.Codec, keeper keeper.Keeper, accountKeeper types.AccountKeeper, - bankKeeper types.BankKeeper, stakingKeeper types.StakingKeeper, poolKeeper types.PoolKeeper, + bankKeeper types.BankKeeper, stakingKeeper types.StakingKeeper, ) AppModule { return AppModule{ cdc: cdc, @@ -62,7 +61,6 @@ func NewAppModule( accountKeeper: accountKeeper, bankKeeper: bankKeeper, stakingKeeper: stakingKeeper, - poolKeeper: poolKeeper, } } diff --git a/x/distribution/testutil/expected_keepers_mocks.go b/x/distribution/testutil/expected_keepers_mocks.go index a2a2d669f861..e30590d865e9 100644 --- a/x/distribution/testutil/expected_keepers_mocks.go +++ b/x/distribution/testutil/expected_keepers_mocks.go @@ -240,86 +240,6 @@ func (mr *MockBankKeeperMockRecorder) SpendableCoins(ctx, addr interface{}) *gom return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SpendableCoins", reflect.TypeOf((*MockBankKeeper)(nil).SpendableCoins), ctx, addr) } -// MockPoolKeeper is a mock of PoolKeeper interface. -type MockPoolKeeper struct { - ctrl *gomock.Controller - recorder *MockPoolKeeperMockRecorder -} - -// MockPoolKeeperMockRecorder is the mock recorder for MockPoolKeeper. -type MockPoolKeeperMockRecorder struct { - mock *MockPoolKeeper -} - -// NewMockPoolKeeper creates a new mock instance. -func NewMockPoolKeeper(ctrl *gomock.Controller) *MockPoolKeeper { - mock := &MockPoolKeeper{ctrl: ctrl} - mock.recorder = &MockPoolKeeperMockRecorder{mock} - return mock -} - -// EXPECT returns an object that allows the caller to indicate expected use. -func (m *MockPoolKeeper) EXPECT() *MockPoolKeeperMockRecorder { - return m.recorder -} - -// DistributeFromCommunityPool mocks base method. -func (m *MockPoolKeeper) DistributeFromCommunityPool(ctx context.Context, amount types0.Coins, receiveAddr types0.AccAddress) error { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "DistributeFromCommunityPool", ctx, amount, receiveAddr) - ret0, _ := ret[0].(error) - return ret0 -} - -// DistributeFromCommunityPool indicates an expected call of DistributeFromCommunityPool. -func (mr *MockPoolKeeperMockRecorder) DistributeFromCommunityPool(ctx, amount, receiveAddr interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DistributeFromCommunityPool", reflect.TypeOf((*MockPoolKeeper)(nil).DistributeFromCommunityPool), ctx, amount, receiveAddr) -} - -// FundCommunityPool mocks base method. -func (m *MockPoolKeeper) FundCommunityPool(ctx context.Context, amount types0.Coins, sender types0.AccAddress) error { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "FundCommunityPool", ctx, amount, sender) - ret0, _ := ret[0].(error) - return ret0 -} - -// FundCommunityPool indicates an expected call of FundCommunityPool. -func (mr *MockPoolKeeperMockRecorder) FundCommunityPool(ctx, amount, sender interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FundCommunityPool", reflect.TypeOf((*MockPoolKeeper)(nil).FundCommunityPool), ctx, amount, sender) -} - -// GetCommunityPool mocks base method. -func (m *MockPoolKeeper) GetCommunityPool(ctx context.Context) (types0.Coins, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "GetCommunityPool", ctx) - ret0, _ := ret[0].(types0.Coins) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// GetCommunityPool indicates an expected call of GetCommunityPool. -func (mr *MockPoolKeeperMockRecorder) GetCommunityPool(ctx interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetCommunityPool", reflect.TypeOf((*MockPoolKeeper)(nil).GetCommunityPool), ctx) -} - -// SetToDistribute mocks base method. -func (m *MockPoolKeeper) SetToDistribute(ctx context.Context, amount types0.Coins, addr string) error { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "SetToDistribute", ctx, amount, addr) - ret0, _ := ret[0].(error) - return ret0 -} - -// SetToDistribute indicates an expected call of SetToDistribute. -func (mr *MockPoolKeeperMockRecorder) SetToDistribute(ctx, amount, addr interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetToDistribute", reflect.TypeOf((*MockPoolKeeper)(nil).SetToDistribute), ctx, amount, addr) -} - // MockStakingKeeper is a mock of StakingKeeper interface. type MockStakingKeeper struct { ctrl *gomock.Controller diff --git a/x/distribution/types/expected_keepers.go b/x/distribution/types/expected_keepers.go index e0fa03dbb1e5..8288f2206280 100644 --- a/x/distribution/types/expected_keepers.go +++ b/x/distribution/types/expected_keepers.go @@ -34,14 +34,6 @@ type BankKeeper interface { IsSendEnabledDenom(ctx context.Context, denom string) bool } -// PoolKeeper defines the expected interface needed to fund & distribute pool balances. -type PoolKeeper interface { - FundCommunityPool(ctx context.Context, amount sdk.Coins, sender sdk.AccAddress) error - DistributeFromCommunityPool(ctx context.Context, amount sdk.Coins, receiveAddr sdk.AccAddress) error - GetCommunityPool(ctx context.Context) (sdk.Coins, error) - SetToDistribute(ctx context.Context, amount sdk.Coins, addr string) error -} - // StakingKeeper expected staking keeper (noalias) type StakingKeeper interface { ValidatorAddressCodec() address.Codec diff --git a/x/distribution/types/keys.go b/x/distribution/types/keys.go index e4409d9d5959..cee527708b85 100644 --- a/x/distribution/types/keys.go +++ b/x/distribution/types/keys.go @@ -24,7 +24,12 @@ const ( // It should be synced with the gov module's name if it is ever changed. // See: https://github.com/cosmos/cosmos-sdk/blob/b62a28aac041829da5ded4aeacfcd7a42873d1c8/x/gov/types/keys.go#L9 GovModuleName = "gov" - // ProtocolPoolModuleName duplicates the protocolpool module's name to avoid a cyclic dependency with x/protocolpool. + // ProtocolPoolDistrAccount duplicates the protocolpool_distr accounts's name to avoid a cyclic dependency with x/protocolpool. + // This account is an intermediary account that holds the funds to be distributed to the protocolpool accounts. + ProtocolPoolDistrAccount = "protocolpool_distr" + + // ProtocolPoolModuleName duplicates the protocolpool accounts's name to avoid a cyclic dependency with x/protocolpool. + // DO NOT USE: This is only used in deprecated methods CommunityPoolSpend, FundCommunityPool and query CommunityPool. ProtocolPoolModuleName = "protocolpool" ) diff --git a/x/gov/testutil/expected_keepers.go b/x/gov/testutil/expected_keepers.go index 987a7a895eb5..9da4b7156638 100644 --- a/x/gov/testutil/expected_keepers.go +++ b/x/gov/testutil/expected_keepers.go @@ -43,7 +43,7 @@ type BankKeeper interface { // PoolKeeper extends the gov's actual expected PoolKeeper. type PoolKeeper interface { - FundCommunityPool(ctx context.Context, amount sdk.Coins, sender sdk.AccAddress) error + FundCommunityPool(ctx context.Context, amount sdk.Coins, sender []byte) error } // StakingKeeper extends gov's actual expected StakingKeeper with additional diff --git a/x/gov/testutil/expected_keepers_mocks.go b/x/gov/testutil/expected_keepers_mocks.go index ea9e9e535bcb..4636f53df68e 100644 --- a/x/gov/testutil/expected_keepers_mocks.go +++ b/x/gov/testutil/expected_keepers_mocks.go @@ -290,7 +290,7 @@ func (m *MockPoolKeeper) EXPECT() *MockPoolKeeperMockRecorder { } // FundCommunityPool mocks base method. -func (m *MockPoolKeeper) FundCommunityPool(ctx context.Context, amount types.Coins, sender types.AccAddress) error { +func (m *MockPoolKeeper) FundCommunityPool(ctx context.Context, amount types.Coins, sender []byte) error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "FundCommunityPool", ctx, amount, sender) ret0, _ := ret[0].(error) diff --git a/x/gov/types/expected_keepers.go b/x/gov/types/expected_keepers.go index 31d19af74d64..7a14d90dbe6d 100644 --- a/x/gov/types/expected_keepers.go +++ b/x/gov/types/expected_keepers.go @@ -51,7 +51,7 @@ type BankKeeper interface { // PoolKeeper defines the expected interface needed to fund & distribute pool balances. type PoolKeeper interface { - FundCommunityPool(ctx context.Context, amount sdk.Coins, sender sdk.AccAddress) error + FundCommunityPool(ctx context.Context, amount sdk.Coins, sender []byte) error } // Event Hooks diff --git a/x/protocolpool/CHANGELOG.md b/x/protocolpool/CHANGELOG.md new file mode 100644 index 000000000000..71b686118198 --- /dev/null +++ b/x/protocolpool/CHANGELOG.md @@ -0,0 +1,30 @@ + + +# Changelog + +## [Unreleased] + +### Improvements + +* [#20790](https://github.com/cosmos/cosmos-sdk/pull/20790) `x/protocolpool` now has its own BeginBlock. diff --git a/x/protocolpool/keeper/genesis.go b/x/protocolpool/keeper/genesis.go index b7da5a204bc6..fa32a08f9a50 100644 --- a/x/protocolpool/keeper/genesis.go +++ b/x/protocolpool/keeper/genesis.go @@ -3,7 +3,9 @@ package keeper import ( "context" "fmt" + "time" + "cosmossdk.io/math" "cosmossdk.io/x/protocolpool/types" sdk "github.com/cosmos/cosmos-sdk/types" @@ -49,8 +51,21 @@ func (k Keeper) InitGenesis(ctx context.Context, data *types.GenesisState) error } } - if err := k.ToDistribute.Set(ctx, data.ToDistribute); err != nil { - return fmt.Errorf("failed to set to distribute: %w", err) + if err := k.LastBalance.Set(ctx, data.LastBalance); err != nil { + return fmt.Errorf("failed to set last balance: %w", err) + } + + totalToBeDistributed := math.ZeroInt() + for _, distribution := range data.Distributions { + totalToBeDistributed = totalToBeDistributed.Add(distribution.Amount) + if err := k.Distributions.Set(ctx, *distribution.Time, distribution.Amount); err != nil { + return fmt.Errorf("failed to set distribution: %w", err) + } + } + + // sanity check to avoid trying to distribute more than what is available + if data.LastBalance.LT(totalToBeDistributed) { + return fmt.Errorf("total to be distributed is greater than the last balance") } return nil @@ -96,7 +111,19 @@ func (k Keeper) ExportGenesis(ctx context.Context) (*types.GenesisState, error) genState := types.NewGenesisState(cf, budget) - genState.ToDistribute, err = k.ToDistribute.Get(ctx) + genState.LastBalance, err = k.LastBalance.Get(ctx) + if err != nil { + return nil, err + } + + err = k.Distributions.Walk(ctx, nil, func(key time.Time, value math.Int) (stop bool, err error) { + genState.Distributions = append(genState.Distributions, &types.Distribution{ + Time: &key, + Amount: value, + }) + + return false, nil + }) if err != nil { return nil, err } diff --git a/x/protocolpool/keeper/genesis_test.go b/x/protocolpool/keeper/genesis_test.go index 4653ff616305..f0149f662787 100644 --- a/x/protocolpool/keeper/genesis_test.go +++ b/x/protocolpool/keeper/genesis_test.go @@ -31,7 +31,17 @@ func (suite *KeeperTestSuite) TestInitGenesis() { }, ) + gs.Distributions = append(gs.Distributions, &types.Distribution{ + Amount: math.OneInt(), + Time: &time.Time{}, + }) + err := suite.poolKeeper.InitGenesis(suite.ctx, gs) + suite.Require().ErrorContains(err, "total to be distributed is greater than the last balance") + + // Set last balance + gs.LastBalance = math.NewInt(1) + err = suite.poolKeeper.InitGenesis(suite.ctx, gs) suite.Require().NoError(err) // Export @@ -39,4 +49,5 @@ func (suite *KeeperTestSuite) TestInitGenesis() { suite.Require().NoError(err) suite.Require().Equal(gs.ContinuousFund, exportedGenState.ContinuousFund) suite.Require().Equal(gs.Budget, exportedGenState.Budget) + suite.Require().Equal(math.OneInt(), exportedGenState.LastBalance) } diff --git a/x/protocolpool/keeper/keeper.go b/x/protocolpool/keeper/keeper.go index 038fd3260d88..f74b10af9862 100644 --- a/x/protocolpool/keeper/keeper.go +++ b/x/protocolpool/keeper/keeper.go @@ -1,10 +1,10 @@ package keeper import ( - "bytes" "context" "errors" "fmt" + "sort" "time" "cosmossdk.io/collections" @@ -35,8 +35,8 @@ type Keeper struct { ContinuousFund collections.Map[sdk.AccAddress, types.ContinuousFund] // RecipientFundDistribution key: RecipientAddr | value: Claimable amount RecipientFundDistribution collections.Map[sdk.AccAddress, math.Int] - // ToDistribute is to keep track of funds to be distributed. It gets zeroed out in iterateAndUpdateFundsDistribution. - ToDistribute collections.Item[math.Int] + Distributions collections.Map[time.Time, math.Int] // key: time.Time | value: amount + LastBalance collections.Item[math.Int] } func NewKeeper(cdc codec.BinaryCodec, env appmodule.Environment, ak types.AccountKeeper, bk types.BankKeeper, sk types.StakingKeeper, authority string, @@ -49,6 +49,10 @@ func NewKeeper(cdc codec.BinaryCodec, env appmodule.Environment, ak types.Accoun if addr := ak.GetModuleAddress(types.StreamAccount); addr == nil { panic(fmt.Sprintf("%s module account has not been set", types.StreamAccount)) } + // ensure protocol pool distribution account is set + if addr := ak.GetModuleAddress(types.ProtocolPoolDistrAccount); addr == nil { + panic(fmt.Sprintf("%s module account has not been set", types.ProtocolPoolDistrAccount)) + } sb := collections.NewSchemaBuilder(env.KVStoreService) @@ -62,7 +66,8 @@ func NewKeeper(cdc codec.BinaryCodec, env appmodule.Environment, ak types.Accoun BudgetProposal: collections.NewMap(sb, types.BudgetKey, "budget", sdk.AccAddressKey, codec.CollValue[types.Budget](cdc)), ContinuousFund: collections.NewMap(sb, types.ContinuousFundKey, "continuous_fund", sdk.AccAddressKey, codec.CollValue[types.ContinuousFund](cdc)), RecipientFundDistribution: collections.NewMap(sb, types.RecipientFundDistributionKey, "recipient_fund_distribution", sdk.AccAddressKey, sdk.IntValue), - ToDistribute: collections.NewItem(sb, types.ToDistributeKey, "to_distribute", sdk.IntValue), + Distributions: collections.NewMap(sb, types.DistributionsKey, "distributions", sdk.TimeKey, sdk.IntValue), + LastBalance: collections.NewItem(sb, types.LastBalanceKey, "last_balance", sdk.IntValue), } schema, err := sb.Build() @@ -80,19 +85,19 @@ func (k Keeper) GetAuthority() string { } // FundCommunityPool allows an account to directly fund the community fund pool. -func (k Keeper) FundCommunityPool(ctx context.Context, amount sdk.Coins, sender sdk.AccAddress) error { +func (k Keeper) FundCommunityPool(ctx context.Context, amount sdk.Coins, sender []byte) error { return k.bankKeeper.SendCoinsFromAccountToModule(ctx, sender, types.ModuleName, amount) } // DistributeFromCommunityPool distributes funds from the protocolpool module account to // a receiver address. -func (k Keeper) DistributeFromCommunityPool(ctx context.Context, amount sdk.Coins, receiveAddr sdk.AccAddress) error { +func (k Keeper) DistributeFromCommunityPool(ctx context.Context, amount sdk.Coins, receiveAddr []byte) error { return k.bankKeeper.SendCoinsFromModuleToAccount(ctx, types.ModuleName, receiveAddr, amount) } // DistributeFromStreamFunds distributes funds from the protocolpool's stream module account to // a receiver address. -func (k Keeper) DistributeFromStreamFunds(ctx context.Context, amount sdk.Coins, receiveAddr sdk.AccAddress) error { +func (k Keeper) DistributeFromStreamFunds(ctx context.Context, amount sdk.Coins, receiveAddr []byte) error { return k.bankKeeper.SendCoinsFromModuleToAccount(ctx, types.StreamAccount, receiveAddr, amount) } @@ -100,48 +105,17 @@ func (k Keeper) DistributeFromStreamFunds(ctx context.Context, amount sdk.Coins, func (k Keeper) GetCommunityPool(ctx context.Context) (sdk.Coins, error) { moduleAccount := k.authKeeper.GetModuleAccount(ctx, types.ModuleName) if moduleAccount == nil { - return nil, errorsmod.Wrapf(sdkerrors.ErrUnknownAddress, "module account %s does not exist", moduleAccount) + return nil, errorsmod.Wrapf(sdkerrors.ErrUnknownAddress, "module account %s does not exist", types.ModuleName) } return k.bankKeeper.GetAllBalances(ctx, moduleAccount.GetAddress()), nil } -func (k Keeper) withdrawContinuousFund(ctx context.Context, recipientAddr string) (sdk.Coin, error) { - recipient, err := k.authKeeper.AddressCodec().StringToBytes(recipientAddr) - if err != nil { - return sdk.Coin{}, sdkerrors.ErrInvalidAddress.Wrapf("invalid recipient address: %s", err) - } - - cf, err := k.ContinuousFund.Get(ctx, recipient) - if err != nil { - if errors.Is(err, collections.ErrNotFound) { - return sdk.Coin{}, fmt.Errorf("no continuous fund found for recipient: %s", recipientAddr) - } - return sdk.Coin{}, fmt.Errorf("get continuous fund failed for recipient: %s", recipientAddr) - } - if cf.Expiry != nil && cf.Expiry.Before(k.HeaderService.HeaderInfo(ctx).Time) { - return sdk.Coin{}, fmt.Errorf("cannot withdraw continuous funds: continuous fund expired for recipient: %s", recipientAddr) - } - - err = k.IterateAndUpdateFundsDistribution(ctx) - if err != nil { - return sdk.Coin{}, fmt.Errorf("error while iterating all the continuous funds: %w", err) - } - - // withdraw continuous fund - withdrawnAmount, err := k.withdrawRecipientFunds(ctx, recipient) - if err != nil { - return sdk.Coin{}, fmt.Errorf("error while withdrawing recipient funds for recipient: %s", recipientAddr) - } - - return withdrawnAmount, nil -} - func (k Keeper) withdrawRecipientFunds(ctx context.Context, recipient []byte) (sdk.Coin, error) { // get allocated continuous fund fundsAllocated, err := k.RecipientFundDistribution.Get(ctx, recipient) if err != nil { if errors.Is(err, collections.ErrNotFound) { - return sdk.Coin{}, types.ErrNoRecipientFund + return sdk.Coin{}, types.ErrNoRecipientFound } return sdk.Coin{}, err } @@ -166,20 +140,12 @@ func (k Keeper) withdrawRecipientFunds(ctx context.Context, recipient []byte) (s return withdrawnAmount, nil } -// SetToDistribute sets the amount to be distributed among recipients, usually called by x/distribution while allocating -// reward and fee distribution. -// This could be only set by the authority address. -func (k Keeper) SetToDistribute(ctx context.Context, amount sdk.Coins, addr string) error { - authAddr, err := k.authKeeper.AddressCodec().StringToBytes(addr) - if err != nil { - return err - } - hasPermission, err := k.hasPermission(authAddr) - if err != nil { - return err - } - if !hasPermission { - return sdkerrors.ErrUnauthorized +// SetToDistribute sets the amount to be distributed among recipients. +func (k Keeper) SetToDistribute(ctx context.Context) error { + // Get current balance of the intermediary module account + moduleAccount := k.authKeeper.GetModuleAccount(ctx, types.ProtocolPoolDistrAccount) + if moduleAccount == nil { + return errorsmod.Wrapf(sdkerrors.ErrUnknownAddress, "module account %s does not exist", types.ProtocolPoolDistrAccount) } denom, err := k.stakingKeeper.BondDenom(ctx) @@ -187,116 +153,154 @@ func (k Keeper) SetToDistribute(ctx context.Context, amount sdk.Coins, addr stri return err } - totalStreamFundsPercentage := math.LegacyZeroDec() - err = k.ContinuousFund.Walk(ctx, nil, func(key sdk.AccAddress, cf types.ContinuousFund) (stop bool, err error) { - // Check if the continuous fund has expired - if cf.Expiry != nil && cf.Expiry.Before(k.HeaderService.HeaderInfo(ctx).Time) { - return false, nil - } - - totalStreamFundsPercentage = totalStreamFundsPercentage.Add(cf.Percentage) - if totalStreamFundsPercentage.GT(math.LegacyOneDec()) { - return true, errors.New("total funds percentage cannot exceed 100") - } - - return false, nil - }) - if err != nil { - return err - } + currentBalance := k.bankKeeper.GetAllBalances(ctx, moduleAccount.GetAddress()) + distributionBalance := currentBalance.AmountOf(denom) - // if percentage is 0 then return early - if totalStreamFundsPercentage.IsZero() { + // if the balance is zero, return early + if distributionBalance.IsZero() { return nil } - // send streaming funds to the stream module account - toDistributeAmt := math.LegacyNewDecFromInt(amount.AmountOf(denom)).Mul(totalStreamFundsPercentage).TruncateInt() - streamAmt := sdk.NewCoins(sdk.NewCoin(denom, toDistributeAmt)) - if err := k.bankKeeper.SendCoinsFromModuleToModule(ctx, types.ModuleName, types.StreamAccount, streamAmt); err != nil { - return err - } - - amountToDistribute, err := k.ToDistribute.Get(ctx) + lastBalance, err := k.LastBalance.Get(ctx) if err != nil { if errors.Is(err, collections.ErrNotFound) { - amountToDistribute = math.ZeroInt() + lastBalance = math.ZeroInt() } else { return err } } - err = k.ToDistribute.Set(ctx, amountToDistribute.Add(amount.AmountOf(denom))) - if err != nil { - return fmt.Errorf("error while setting ToDistribute: %w", err) - } - return nil -} + // Calculate the amount to be distributed + amountToDistribute := distributionBalance.Sub(lastBalance) -func (k Keeper) hasPermission(addr []byte) (bool, error) { - authority := k.GetAuthority() - authAcc, err := k.authKeeper.AddressCodec().StringToBytes(authority) - if err != nil { - return false, err + if err = k.Distributions.Set(ctx, k.HeaderService.HeaderInfo(ctx).Time, amountToDistribute); err != nil { + return fmt.Errorf("error while setting Distributions: %w", err) } - return bytes.Equal(authAcc, addr), nil + // Update the last balance + return k.LastBalance.Set(ctx, distributionBalance) } func (k Keeper) IterateAndUpdateFundsDistribution(ctx context.Context) error { - toDistributeAmount, err := k.ToDistribute.Get(ctx) + // first we get all the continuous funds, and keep a list of the ones that expired so we can delete later + funds := []types.ContinuousFund{} + toDelete := [][]byte{} + err := k.ContinuousFund.Walk(ctx, nil, func(key sdk.AccAddress, cf types.ContinuousFund) (stop bool, err error) { + funds = append(funds, cf) + + // check if the continuous fund has expired, and add it to the list of funds to delete + if cf.Expiry != nil && cf.Expiry.Before(k.HeaderService.HeaderInfo(ctx).Time) { + toDelete = append(toDelete, key) + } + + return false, nil + }) if err != nil { return err } - // if there are no funds to distribute, return - if toDistributeAmount.IsZero() { - return nil + // next we iterate over the distributions, calculate each recipient's share and the remaining pool funds + toDistribute := map[string]math.Int{} + poolFunds := math.ZeroInt() + fullAmountToDistribute := math.ZeroInt() + + if err = k.Distributions.Walk(ctx, nil, func(key time.Time, amount math.Int) (stop bool, err error) { + percentageToDistribute := math.LegacyZeroDec() + for _, f := range funds { + if f.Expiry != nil && f.Expiry.Before(key) { + continue + } + + percentageToDistribute = percentageToDistribute.Add(f.Percentage) + + _, ok := toDistribute[f.Recipient] + if !ok { + toDistribute[f.Recipient] = math.ZeroInt() + } + amountToDistribute := f.Percentage.MulInt(amount).TruncateInt() + toDistribute[f.Recipient] = toDistribute[f.Recipient].Add(amountToDistribute) + fullAmountToDistribute = fullAmountToDistribute.Add(amountToDistribute) + } + + // sanity check for max percentage + if percentageToDistribute.GT(math.LegacyOneDec()) { + return true, errors.New("total funds percentage cannot exceed 100") + } + + remaining := math.LegacyOneDec().Sub(percentageToDistribute).MulInt(amount).RoundInt() + poolFunds = poolFunds.Add(remaining) + + return false, nil + }); err != nil { + return err } - totalPercentageToBeDistributed := math.LegacyZeroDec() + // clear the distributions and reset the last balance + if err = k.Distributions.Clear(ctx, nil); err != nil { + return err + } - denom, err := k.stakingKeeper.BondDenom(ctx) + if err = k.LastBalance.Set(ctx, math.ZeroInt()); err != nil { + return err + } + + // send the funds to the stream account to be distributed later, and the remaining to the community pool + bondDenom, err := k.stakingKeeper.BondDenom(ctx) if err != nil { return err } - toDistributeDec := sdk.NewDecCoin(denom, toDistributeAmount) - // Calculate totalPercentageToBeDistributed and store values - err = k.ContinuousFund.Walk(ctx, nil, func(key sdk.AccAddress, cf types.ContinuousFund) (stop bool, err error) { - // Check if the continuous fund has expired - if cf.Expiry != nil && cf.Expiry.Before(k.HeaderService.HeaderInfo(ctx).Time) { - return false, nil + streamAmt := sdk.NewCoins(sdk.NewCoin(bondDenom, fullAmountToDistribute)) + if !streamAmt.IsZero() { + if err := k.bankKeeper.SendCoinsFromModuleToModule(ctx, types.ProtocolPoolDistrAccount, types.StreamAccount, streamAmt); err != nil { + return err } + } - // sanity check for max percentage - totalPercentageToBeDistributed = totalPercentageToBeDistributed.Add(cf.Percentage) - if totalPercentageToBeDistributed.GT(math.LegacyOneDec()) { - return true, errors.New("total funds percentage cannot exceed 100") + if !poolFunds.IsZero() { + poolCoins := sdk.NewCoins(sdk.NewCoin(bondDenom, poolFunds)) + if err := k.bankKeeper.SendCoinsFromModuleToModule(ctx, types.ProtocolPoolDistrAccount, types.ModuleName, poolCoins); err != nil { + return err } + } - // Calculate the funds to be distributed based on the percentage - recipientAmount := toDistributeDec.Amount.Mul(cf.Percentage).TruncateInt() + // update the recipient fund distribution, first get the keys and sort them + recipients := make([]string, 0, len(toDistribute)) + for k2 := range toDistribute { + recipients = append(recipients, k2) + } + sort.Strings(recipients) + for _, recipient := range recipients { // Set funds to be claimed - toClaim, err := k.RecipientFundDistribution.Get(ctx, key) + bzAddr, err := k.authKeeper.AddressCodec().StringToBytes(recipient) if err != nil { - return true, err + return err } - amount := toClaim.Add(recipientAmount) - err = k.RecipientFundDistribution.Set(ctx, key, amount) + + toClaim, err := k.RecipientFundDistribution.Get(ctx, bzAddr) if err != nil { - return true, err + if errors.Is(err, collections.ErrNotFound) { + toClaim = math.ZeroInt() + } else { + return err + } } - return false, nil - }) - if err != nil { - return err + amount := toClaim.Add(toDistribute[recipient]) + if err = k.RecipientFundDistribution.Set(ctx, bzAddr, amount); err != nil { + return err + } + } + + // delete expired continuous funds + for _, recipient := range toDelete { + if err = k.ContinuousFund.Remove(ctx, recipient); err != nil { + return err + } } - // Set the coins to be distributed from toDistribute to 0 - return k.ToDistribute.Set(ctx, math.ZeroInt()) + return nil } func (k Keeper) claimFunds(ctx context.Context, recipientAddr string) (amount sdk.Coin, err error) { @@ -472,3 +476,7 @@ func (k Keeper) validateContinuousFund(ctx context.Context, msg types.MsgCreateC return nil } + +func (k Keeper) BeginBlocker(ctx context.Context) error { + return k.SetToDistribute(ctx) +} diff --git a/x/protocolpool/keeper/keeper_test.go b/x/protocolpool/keeper/keeper_test.go index ddfcd6d82415..1f5b1f1bce0f 100644 --- a/x/protocolpool/keeper/keeper_test.go +++ b/x/protocolpool/keeper/keeper_test.go @@ -27,8 +27,9 @@ import ( ) var ( - poolAcc = authtypes.NewEmptyModuleAccount(types.ModuleName) - streamAcc = authtypes.NewEmptyModuleAccount(types.StreamAccount) + poolAcc = authtypes.NewEmptyModuleAccount(types.ModuleName) + streamAcc = authtypes.NewEmptyModuleAccount(types.StreamAccount) + poolDistrAcc = authtypes.NewEmptyModuleAccount(types.ProtocolPoolDistrAccount) ) type KeeperTestSuite struct { @@ -57,6 +58,7 @@ func (s *KeeperTestSuite) SetupTest() { ctrl := gomock.NewController(s.T()) accountKeeper := pooltestutil.NewMockAccountKeeper(ctrl) accountKeeper.EXPECT().GetModuleAddress(types.ModuleName).Return(poolAcc.GetAddress()) + accountKeeper.EXPECT().GetModuleAddress(types.ProtocolPoolDistrAccount).Return(poolDistrAcc.GetAddress()) accountKeeper.EXPECT().AddressCodec().Return(address.NewBech32Codec("cosmos")).AnyTimes() accountKeeper.EXPECT().GetModuleAddress(types.StreamAccount).Return(streamAcc.GetAddress()) s.authKeeper = accountKeeper @@ -102,12 +104,14 @@ func (s *KeeperTestSuite) mockWithdrawContinuousFund() { s.stakingKeeper.EXPECT().BondDenom(gomock.Any()).Return("stake", nil).AnyTimes() } -func (s *KeeperTestSuite) mockStreamFunds() { +func (s *KeeperTestSuite) mockStreamFunds(distributed math.Int) { s.authKeeper.EXPECT().GetModuleAccount(s.ctx, types.ModuleName).Return(poolAcc).AnyTimes() + s.authKeeper.EXPECT().GetModuleAccount(s.ctx, types.ProtocolPoolDistrAccount).Return(poolDistrAcc).AnyTimes() s.authKeeper.EXPECT().GetModuleAddress(types.StreamAccount).Return(streamAcc.GetAddress()).AnyTimes() - distrBal := sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, math.NewInt(100000))) - s.bankKeeper.EXPECT().GetAllBalances(s.ctx, poolAcc.GetAddress()).Return(distrBal).AnyTimes() - s.bankKeeper.EXPECT().SendCoinsFromModuleToModule(s.ctx, poolAcc.GetName(), streamAcc.GetName(), gomock.Any()).AnyTimes() + distrBal := sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, distributed)) + s.bankKeeper.EXPECT().GetAllBalances(s.ctx, poolDistrAcc.GetAddress()).Return(distrBal).AnyTimes() + s.bankKeeper.EXPECT().SendCoinsFromModuleToModule(s.ctx, poolDistrAcc.GetName(), streamAcc.GetName(), gomock.Any()).AnyTimes() + s.bankKeeper.EXPECT().SendCoinsFromModuleToModule(s.ctx, poolDistrAcc.GetName(), poolAcc.GetName(), gomock.Any()).AnyTimes() } func TestKeeperTestSuite(t *testing.T) { @@ -118,10 +122,11 @@ func (s *KeeperTestSuite) TestIterateAndUpdateFundsDistribution() { // We'll create 2 continuous funds of 30% each, and the total pool is 1000000, meaning each fund should get 300000 s.SetupTest() - s.authKeeper.EXPECT().GetModuleAccount(s.ctx, types.ModuleName).Return(poolAcc).AnyTimes() + s.authKeeper.EXPECT().GetModuleAccount(s.ctx, types.ProtocolPoolDistrAccount).Return(poolAcc).AnyTimes() distrBal := sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, math.NewInt(1000000))) s.bankKeeper.EXPECT().GetAllBalances(s.ctx, poolAcc.GetAddress()).Return(distrBal).AnyTimes() - s.bankKeeper.EXPECT().SendCoinsFromModuleToModule(s.ctx, poolAcc.GetName(), streamAcc.GetName(), sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, math.NewInt(600000)))).AnyTimes() + s.bankKeeper.EXPECT().SendCoinsFromModuleToModule(s.ctx, poolDistrAcc.GetName(), streamAcc.GetName(), sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, math.NewInt(600000)))) + s.bankKeeper.EXPECT().SendCoinsFromModuleToModule(s.ctx, poolDistrAcc.GetName(), poolAcc.GetName(), sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, math.NewInt(400000)))) _, err := s.msgServer.CreateContinuousFund(s.ctx, &types.MsgCreateContinuousFund{ Authority: s.poolKeeper.GetAuthority(), @@ -137,7 +142,7 @@ func (s *KeeperTestSuite) TestIterateAndUpdateFundsDistribution() { }) s.Require().NoError(err) - _ = s.poolKeeper.SetToDistribute(s.ctx, sdk.NewCoins(sdk.NewCoin("stake", math.NewInt(1000000))), s.poolKeeper.GetAuthority()) + _ = s.poolKeeper.SetToDistribute(s.ctx) err = s.poolKeeper.IterateAndUpdateFundsDistribution(s.ctx) s.Require().NoError(err) diff --git a/x/protocolpool/keeper/msg_server.go b/x/protocolpool/keeper/msg_server.go index 775826cda755..43caff3e42a2 100644 --- a/x/protocolpool/keeper/msg_server.go +++ b/x/protocolpool/keeper/msg_server.go @@ -139,6 +139,11 @@ func (k MsgServer) CreateContinuousFund(ctx context.Context, msg *types.MsgCreat return nil, fmt.Errorf("cannot set continuous fund proposal\ntotal funds percentage exceeds 100\ncurrent total percentage: %s", totalStreamFundsPercentage.Sub(msg.Percentage).MulInt64(100).TruncateInt().String()) } + // Distribute funds to avoid giving this new fund more than it should get + if err := k.IterateAndUpdateFundsDistribution(ctx); err != nil { + return nil, err + } + // Create continuous fund proposal cf := types.ContinuousFund{ Recipient: msg.Recipient, @@ -161,12 +166,23 @@ func (k MsgServer) CreateContinuousFund(ctx context.Context, msg *types.MsgCreat } func (k MsgServer) WithdrawContinuousFund(ctx context.Context, msg *types.MsgWithdrawContinuousFund) (*types.MsgWithdrawContinuousFundResponse, error) { - amount, err := k.withdrawContinuousFund(ctx, msg.RecipientAddress) + recipient, err := k.authKeeper.AddressCodec().StringToBytes(msg.RecipientAddress) if err != nil { - return nil, err + return nil, sdkerrors.ErrInvalidAddress.Wrapf("invalid recipient address: %s", err) + } + + err = k.IterateAndUpdateFundsDistribution(ctx) + if err != nil { + return nil, fmt.Errorf("error while iterating all the continuous funds: %w", err) + } + + // withdraw continuous fund + withdrawnAmount, err := k.withdrawRecipientFunds(ctx, recipient) + if err != nil { + return nil, fmt.Errorf("error while withdrawing recipient funds for recipient: %w", err) } - return &types.MsgWithdrawContinuousFundResponse{Amount: amount}, nil + return &types.MsgWithdrawContinuousFundResponse{Amount: withdrawnAmount}, nil } func (k MsgServer) CancelContinuousFund(ctx context.Context, msg *types.MsgCancelContinuousFund) (*types.MsgCancelContinuousFundResponse, error) { @@ -182,17 +198,14 @@ func (k MsgServer) CancelContinuousFund(ctx context.Context, msg *types.MsgCance canceledHeight := k.HeaderService.HeaderInfo(ctx).Height canceledTime := k.HeaderService.HeaderInfo(ctx).Time - found, err := k.ContinuousFund.Has(ctx, recipient) - if !found { - return nil, fmt.Errorf("no recipient found to cancel continuous fund: %s", msg.RecipientAddress) - } - if err != nil { + // distribute funds before withdrawing + if err = k.IterateAndUpdateFundsDistribution(ctx); err != nil { return nil, err } // withdraw funds if any are allocated withdrawnFunds, err := k.withdrawRecipientFunds(ctx, recipient) - if err != nil && !errorspkg.Is(err, types.ErrNoRecipientFund) { + if err != nil && !errorspkg.Is(err, types.ErrNoRecipientFound) { return nil, fmt.Errorf("error while withdrawing already allocated funds for recipient %s: %w", msg.RecipientAddress, err) } diff --git a/x/protocolpool/keeper/msg_server_test.go b/x/protocolpool/keeper/msg_server_test.go index 37b122170d71..b053ef9ff681 100644 --- a/x/protocolpool/keeper/msg_server_test.go +++ b/x/protocolpool/keeper/msg_server_test.go @@ -3,6 +3,8 @@ package keeper_test import ( "time" + "github.com/golang/mock/gomock" + "cosmossdk.io/collections" "cosmossdk.io/core/header" "cosmossdk.io/math" @@ -403,7 +405,7 @@ func (suite *KeeperTestSuite) TestWithdrawContinuousFund() { "recipient with no continuous fund": { recipientAddress: []sdk.AccAddress{recipient}, expErr: true, - expErrMsg: "no continuous fund found for recipient", + expErrMsg: "error while withdrawing recipient funds for recipient: no recipient found", }, "funds percentage > 100": { preRun: func() { @@ -441,14 +443,14 @@ func (suite *KeeperTestSuite) TestWithdrawContinuousFund() { suite.Require().NoError(err) // Set ToDistribute - err = suite.poolKeeper.ToDistribute.Set(suite.ctx, math.NewInt(100000)) + err = suite.poolKeeper.Distributions.Set(suite.ctx, suite.ctx.HeaderInfo().Time, math.NewInt(100000)) suite.Require().NoError(err) }, recipientAddress: []sdk.AccAddress{recipient}, expErr: true, expErrMsg: "error while iterating all the continuous funds: total funds percentage cannot exceed 100", }, - "expired case": { + "expired case with no funds left to withdraw": { preRun: func() { percentage, err := math.LegacyNewDecFromStr("0.2") suite.Require().NoError(err) @@ -464,7 +466,7 @@ func (suite *KeeperTestSuite) TestWithdrawContinuousFund() { }, recipientAddress: []sdk.AccAddress{recipient}, expErr: true, - expErrMsg: "cannot withdraw continuous funds: continuous fund expired for recipient", + expErrMsg: "error while withdrawing recipient funds for recipient: no recipient found", }, "valid case with ToDistribute amount zero": { preRun: func() { @@ -483,8 +485,9 @@ func (suite *KeeperTestSuite) TestWithdrawContinuousFund() { // Set recipient fund percentage and recipient fund distribution err = suite.poolKeeper.RecipientFundDistribution.Set(suite.ctx, recipient, math.ZeroInt()) suite.Require().NoError(err) - err = suite.poolKeeper.ToDistribute.Set(suite.ctx, math.ZeroInt()) + err = suite.poolKeeper.Distributions.Set(suite.ctx, suite.ctx.HeaderInfo().Time, math.ZeroInt()) suite.Require().NoError(err) + suite.mockStreamFunds(math.NewInt(0)) }, recipientAddress: []sdk.AccAddress{recipient}, expErr: false, @@ -504,9 +507,8 @@ func (suite *KeeperTestSuite) TestWithdrawContinuousFund() { // Set recipient fund percentage and recipient fund distribution err = suite.poolKeeper.RecipientFundDistribution.Set(suite.ctx, recipient, math.ZeroInt()) suite.Require().NoError(err) - toDistribute := sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, math.NewInt(100000))) - suite.mockStreamFunds() - err = suite.poolKeeper.SetToDistribute(suite.ctx, toDistribute, suite.poolKeeper.GetAuthority()) + suite.mockStreamFunds(math.NewInt(100000)) + err = suite.poolKeeper.SetToDistribute(suite.ctx) suite.Require().NoError(err) }, recipientAddress: []sdk.AccAddress{recipient}, @@ -530,9 +532,8 @@ func (suite *KeeperTestSuite) TestWithdrawContinuousFund() { // Set recipient fund percentage and recipient fund distribution err = suite.poolKeeper.RecipientFundDistribution.Set(suite.ctx, recipient, math.ZeroInt()) suite.Require().NoError(err) - toDistribute := sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, math.NewInt(100000))) - suite.mockStreamFunds() - err = suite.poolKeeper.SetToDistribute(suite.ctx, toDistribute, suite.poolKeeper.GetAuthority()) + suite.mockStreamFunds(math.NewInt(100000)) + err = suite.poolKeeper.SetToDistribute(suite.ctx) suite.Require().NoError(err) }, recipientAddress: []sdk.AccAddress{recipient}, @@ -588,9 +589,8 @@ func (suite *KeeperTestSuite) TestWithdrawContinuousFund() { err = suite.poolKeeper.RecipientFundDistribution.Set(suite.ctx, recipient3, math.ZeroInt()) suite.Require().NoError(err) - toDistribute := sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, math.NewInt(100000))) - suite.mockStreamFunds() - err = suite.poolKeeper.SetToDistribute(suite.ctx, toDistribute, suite.poolKeeper.GetAuthority()) + suite.mockStreamFunds(math.NewInt(100000)) + err = suite.poolKeeper.SetToDistribute(suite.ctx) suite.Require().NoError(err) }, recipientAddress: []sdk.AccAddress{recipient, recipient2, recipient3}, @@ -813,11 +813,6 @@ func (suite *KeeperTestSuite) TestCancelContinuousFund() { expErr: true, expErrMsg: "empty address string is not allowed", }, - "no recipient found": { - recipientAddr: recipientAddr, - expErr: true, - expErrMsg: "no recipient found to cancel continuous fund", - }, "all good with unclaimed funds for recipient": { preRun: func() { // Set fund 1 @@ -853,9 +848,8 @@ func (suite *KeeperTestSuite) TestCancelContinuousFund() { suite.Require().NoError(err) // Set ToDistribute - toDistribute := sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, math.NewInt(100000))) - suite.mockStreamFunds() - err = suite.poolKeeper.SetToDistribute(suite.ctx, toDistribute, suite.poolKeeper.GetAuthority()) + suite.mockStreamFunds(math.NewInt(100000)) + err = suite.poolKeeper.SetToDistribute(suite.ctx) suite.Require().NoError(err) // withdraw funds for fund request 2 @@ -960,9 +954,8 @@ func (suite *KeeperTestSuite) TestWithdrawExpiredFunds() { }) suite.Require().NoError(err) - toDistribute := sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, math.NewInt(100000))) - suite.mockStreamFunds() - err = suite.poolKeeper.SetToDistribute(suite.ctx, toDistribute, suite.poolKeeper.GetAuthority()) + suite.mockStreamFunds(math.NewInt(100000)) + err = suite.poolKeeper.SetToDistribute(suite.ctx) suite.Require().NoError(err) suite.mockWithdrawContinuousFund() @@ -973,11 +966,17 @@ func (suite *KeeperTestSuite) TestWithdrawExpiredFunds() { header.Time = expiration.Add(1 * time.Second) suite.ctx = suite.ctx.WithHeaderInfo(header) - _, err = suite.msgServer.WithdrawContinuousFund(suite.ctx, &types.MsgWithdrawContinuousFund{RecipientAddress: recipientStrAddr}) - suite.Require().ErrorContains(err, "continuous fund expired for recipient") + // If we keep calling WithdrawContinuousFund, it should not error and return always an amount of 0 + withdrawRes, err := suite.msgServer.WithdrawContinuousFund(suite.ctx, &types.MsgWithdrawContinuousFund{RecipientAddress: recipientStrAddr}) + suite.Require().True(withdrawRes.Amount.IsZero()) + suite.Require().NoError(err) + + withdrawRes, err = suite.msgServer.WithdrawContinuousFund(suite.ctx, &types.MsgWithdrawContinuousFund{RecipientAddress: recipientStrAddr}) + suite.Require().True(withdrawRes.Amount.IsZero()) + suite.Require().NoError(err) - suite.mockStreamFunds() - err = suite.poolKeeper.SetToDistribute(suite.ctx, toDistribute, suite.poolKeeper.GetAuthority()) + suite.mockStreamFunds(math.NewInt(100000)) + err = suite.poolKeeper.SetToDistribute(suite.ctx) suite.Require().NoError(err) suite.mockWithdrawContinuousFund() @@ -985,9 +984,58 @@ func (suite *KeeperTestSuite) TestWithdrawExpiredFunds() { suite.Require().NoError(err) res, err := suite.msgServer.CancelContinuousFund(suite.ctx, &types.MsgCancelContinuousFund{ + Authority: suite.poolKeeper.GetAuthority(), + RecipientAddress: recipient2StrAddr, + }) + suite.Require().NoError(err) + suite.Require().Equal(sdk.NewCoin(sdk.DefaultBondDenom, math.NewInt(0)), res.WithdrawnAllocatedFund) + + // canceling an expired continuous fund, won't error + res, err = suite.msgServer.CancelContinuousFund(suite.ctx, &types.MsgCancelContinuousFund{ Authority: suite.poolKeeper.GetAuthority(), RecipientAddress: recipientStrAddr, }) suite.Require().NoError(err) suite.Require().Equal(sdk.NewCoin(sdk.DefaultBondDenom, math.NewInt(0)), res.WithdrawnAllocatedFund) + + // if we try to cancel again the same continuout fund, it won't error, it will still distribute funds if needed. + res, err = suite.msgServer.CancelContinuousFund(suite.ctx, &types.MsgCancelContinuousFund{ + Authority: suite.poolKeeper.GetAuthority(), + RecipientAddress: recipientStrAddr, + }) + suite.Require().NoError(err) + suite.Require().True(res.WithdrawnAllocatedFund.IsNil()) +} + +func (suite *KeeperTestSuite) TestFundCommunityPool() { + sender := []byte("fundingAddr1____________________") + addrCodec := codectestutil.CodecOptions{}.GetAddressCodec() + senderAddr, err := addrCodec.BytesToString(sender) + suite.Require().NoError(err) + + amount := sdk.NewCoins(sdk.NewInt64Coin(sdk.DefaultBondDenom, 1000000)) + suite.bankKeeper.EXPECT().SendCoinsFromAccountToModule(gomock.Any(), sender, types.ModuleName, amount).Return(nil).Times(1) + + _, err = suite.msgServer.FundCommunityPool(suite.ctx, &types.MsgFundCommunityPool{ + Amount: amount, + Depositor: senderAddr, + }) + suite.Require().NoError(err) +} + +func (suite *KeeperTestSuite) TestCommunityPoolSpend() { + recipient := []byte("fundingAddr1____________________") + addrCodec := codectestutil.CodecOptions{}.GetAddressCodec() + recipientAddr, err := addrCodec.BytesToString(recipient) + suite.Require().NoError(err) + + amount := sdk.NewCoins(sdk.NewInt64Coin(sdk.DefaultBondDenom, 1000000)) + suite.bankKeeper.EXPECT().SendCoinsFromModuleToAccount(gomock.Any(), types.ModuleName, recipient, amount).Return(nil).Times(1) + + _, err = suite.msgServer.CommunityPoolSpend(suite.ctx, &types.MsgCommunityPoolSpend{ + Authority: suite.poolKeeper.GetAuthority(), + Recipient: recipientAddr, + Amount: amount, + }) + suite.Require().NoError(err) } diff --git a/x/protocolpool/module.go b/x/protocolpool/module.go index 882da6eb6fc8..2e88385d54f9 100644 --- a/x/protocolpool/module.go +++ b/x/protocolpool/module.go @@ -29,6 +29,7 @@ var ( _ appmodule.HasServices = AppModule{} _ appmodule.HasGenesis = AppModule{} _ appmodule.HasRegisterInterfaces = AppModule{} + _ appmodule.HasBeginBlocker = AppModule{} ) // AppModule implements an application module for the pool module @@ -112,5 +113,10 @@ func (am AppModule) ExportGenesis(ctx context.Context) (json.RawMessage, error) return am.cdc.MarshalJSON(gs) } +// BeginBlock implements appmodule.HasBeginBlocker. +func (am AppModule) BeginBlock(ctx context.Context) error { + return am.keeper.BeginBlocker(ctx) +} + // ConsensusVersion implements HasConsensusVersion func (AppModule) ConsensusVersion() uint64 { return ConsensusVersion } diff --git a/x/protocolpool/proto/cosmos/protocolpool/v1/genesis.proto b/x/protocolpool/proto/cosmos/protocolpool/v1/genesis.proto index 5730f5257801..d9df6870a7a4 100644 --- a/x/protocolpool/proto/cosmos/protocolpool/v1/genesis.proto +++ b/x/protocolpool/proto/cosmos/protocolpool/v1/genesis.proto @@ -6,6 +6,7 @@ option go_package = "cosmossdk.io/x/protocolpool/types"; import "cosmos/protocolpool/v1/types.proto"; import "gogoproto/gogo.proto"; import "cosmos_proto/cosmos.proto"; +import "google/protobuf/timestamp.proto"; // GenesisState defines the protocolpool module's genesis state. message GenesisState { @@ -14,9 +15,26 @@ message GenesisState { // Budget defines the budget proposals at genesis. repeated Budget budget = 2; - string to_distribute = 3 [ + // last_balance contains the amount of tokens yet to be distributed, will be zero if + // there are no funds to distribute. + string last_balance = 3 [ (cosmos_proto.scalar) = "cosmos.Int", (gogoproto.customtype) = "cosmossdk.io/math.Int", (gogoproto.nullable) = false ]; + + // distributions contains the list of distributions to be made to continuous + // funds and budgets. It contains time in order to distribute to non-expired + // funds only. + repeated Distribution distributions = 4; } + +message Distribution { + string amount = 3 [ + (cosmos_proto.scalar) = "cosmos.Int", + (gogoproto.customtype) = "cosmossdk.io/math.Int", + (gogoproto.nullable) = false + ]; + + google.protobuf.Timestamp time = 6 [(gogoproto.stdtime) = true]; +} \ No newline at end of file diff --git a/x/protocolpool/types/errors.go b/x/protocolpool/types/errors.go index a3790136b971..160e30dc8a21 100644 --- a/x/protocolpool/types/errors.go +++ b/x/protocolpool/types/errors.go @@ -3,6 +3,6 @@ package types import "cosmossdk.io/errors" var ( - ErrInvalidSigner = errors.Register(ModuleName, 2, "expected authority account as only signer for community pool spend message") - ErrNoRecipientFund = errors.Register(ModuleName, 3, "no recipient found") + ErrInvalidSigner = errors.Register(ModuleName, 2, "expected authority account as only signer for community pool spend message") + ErrNoRecipientFound = errors.Register(ModuleName, 3, "no recipient found") ) diff --git a/x/protocolpool/types/genesis.go b/x/protocolpool/types/genesis.go index 632a36573469..08ad95eaf4bd 100644 --- a/x/protocolpool/types/genesis.go +++ b/x/protocolpool/types/genesis.go @@ -13,6 +13,8 @@ func NewGenesisState(cf []*ContinuousFund, budget []*Budget) *GenesisState { return &GenesisState{ ContinuousFund: cf, Budget: budget, + LastBalance: math.ZeroInt(), + Distributions: []*Distribution{}, } } diff --git a/x/protocolpool/types/genesis.pb.go b/x/protocolpool/types/genesis.pb.go index ee3d83938081..8118de396b5e 100644 --- a/x/protocolpool/types/genesis.pb.go +++ b/x/protocolpool/types/genesis.pb.go @@ -9,15 +9,19 @@ import ( _ "github.com/cosmos/cosmos-proto" _ "github.com/cosmos/gogoproto/gogoproto" proto "github.com/cosmos/gogoproto/proto" + github_com_cosmos_gogoproto_types "github.com/cosmos/gogoproto/types" + _ "google.golang.org/protobuf/types/known/timestamppb" io "io" math "math" math_bits "math/bits" + time "time" ) // Reference imports to suppress errors if they are not otherwise used. var _ = proto.Marshal var _ = fmt.Errorf var _ = math.Inf +var _ = time.Kitchen // This is a compile-time assertion to ensure that this generated file // is compatible with the proto package it is being compiled against. @@ -30,8 +34,14 @@ type GenesisState struct { // ContinuousFund defines the continuous funds at genesis. ContinuousFund []*ContinuousFund `protobuf:"bytes,1,rep,name=continuous_fund,json=continuousFund,proto3" json:"continuous_fund,omitempty"` // Budget defines the budget proposals at genesis. - Budget []*Budget `protobuf:"bytes,2,rep,name=budget,proto3" json:"budget,omitempty"` - ToDistribute cosmossdk_io_math.Int `protobuf:"bytes,3,opt,name=to_distribute,json=toDistribute,proto3,customtype=cosmossdk.io/math.Int" json:"to_distribute"` + Budget []*Budget `protobuf:"bytes,2,rep,name=budget,proto3" json:"budget,omitempty"` + // last_balance contains the amount of tokens yet to be distributed, will be zero if + // there are no funds to distribute. + LastBalance cosmossdk_io_math.Int `protobuf:"bytes,3,opt,name=last_balance,json=lastBalance,proto3,customtype=cosmossdk.io/math.Int" json:"last_balance"` + // distributions contains the list of distributions to be made to continuous + // funds and budgets. It contains time in order to distribute to non-expired + // funds only. + Distributions []*Distribution `protobuf:"bytes,4,rep,name=distributions,proto3" json:"distributions,omitempty"` } func (m *GenesisState) Reset() { *m = GenesisState{} } @@ -81,8 +91,61 @@ func (m *GenesisState) GetBudget() []*Budget { return nil } +func (m *GenesisState) GetDistributions() []*Distribution { + if m != nil { + return m.Distributions + } + return nil +} + +type Distribution struct { + Amount cosmossdk_io_math.Int `protobuf:"bytes,3,opt,name=amount,proto3,customtype=cosmossdk.io/math.Int" json:"amount"` + Time *time.Time `protobuf:"bytes,6,opt,name=time,proto3,stdtime" json:"time,omitempty"` +} + +func (m *Distribution) Reset() { *m = Distribution{} } +func (m *Distribution) String() string { return proto.CompactTextString(m) } +func (*Distribution) ProtoMessage() {} +func (*Distribution) Descriptor() ([]byte, []int) { + return fileDescriptor_72560a99455b4146, []int{1} +} +func (m *Distribution) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Distribution) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Distribution.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *Distribution) XXX_Merge(src proto.Message) { + xxx_messageInfo_Distribution.Merge(m, src) +} +func (m *Distribution) XXX_Size() int { + return m.Size() +} +func (m *Distribution) XXX_DiscardUnknown() { + xxx_messageInfo_Distribution.DiscardUnknown(m) +} + +var xxx_messageInfo_Distribution proto.InternalMessageInfo + +func (m *Distribution) GetTime() *time.Time { + if m != nil { + return m.Time + } + return nil +} + func init() { proto.RegisterType((*GenesisState)(nil), "cosmos.protocolpool.v1.GenesisState") + proto.RegisterType((*Distribution)(nil), "cosmos.protocolpool.v1.Distribution") } func init() { @@ -90,26 +153,32 @@ func init() { } var fileDescriptor_72560a99455b4146 = []byte{ - // 290 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0x49, 0xce, 0x2f, 0xce, - 0xcd, 0x2f, 0xd6, 0x2f, 0x28, 0xca, 0x2f, 0xc9, 0x4f, 0xce, 0xcf, 0x29, 0xc8, 0xcf, 0xcf, 0xd1, - 0x2f, 0x33, 0xd4, 0x4f, 0x4f, 0xcd, 0x4b, 0x2d, 0xce, 0x2c, 0xd6, 0x03, 0x8b, 0x0b, 0x89, 0x41, - 0x54, 0xe9, 0x21, 0xab, 0xd2, 0x2b, 0x33, 0x94, 0x52, 0xc2, 0xa1, 0xbb, 0xa4, 0xb2, 0x20, 0x15, - 0xaa, 0x5a, 0x4a, 0x24, 0x3d, 0x3f, 0x3d, 0x1f, 0xcc, 0xd4, 0x07, 0xb1, 0xa0, 0xa2, 0x92, 0x10, - 0x9d, 0xf1, 0x10, 0x09, 0x64, 0xe3, 0x95, 0x5e, 0x32, 0x72, 0xf1, 0xb8, 0x43, 0xac, 0x0f, 0x2e, - 0x49, 0x2c, 0x49, 0x15, 0xf2, 0xe7, 0xe2, 0x4f, 0xce, 0xcf, 0x2b, 0xc9, 0xcc, 0x2b, 0xcd, 0x2f, - 0x2d, 0x8e, 0x4f, 0x2b, 0xcd, 0x4b, 0x91, 0x60, 0x54, 0x60, 0xd6, 0xe0, 0x36, 0x52, 0xd3, 0xc3, - 0xee, 0x2e, 0x3d, 0x67, 0xb8, 0x72, 0xb7, 0xd2, 0xbc, 0x94, 0x20, 0xbe, 0x64, 0x14, 0xbe, 0x90, - 0x19, 0x17, 0x5b, 0x52, 0x69, 0x4a, 0x7a, 0x6a, 0x89, 0x04, 0x13, 0xd8, 0x1c, 0x39, 0x5c, 0xe6, - 0x38, 0x81, 0x55, 0x05, 0x41, 0x55, 0x0b, 0x05, 0x70, 0xf1, 0x96, 0xe4, 0xc7, 0xa7, 0x64, 0x16, - 0x97, 0x14, 0x65, 0x26, 0x95, 0x96, 0xa4, 0x4a, 0x30, 0x2b, 0x30, 0x6a, 0x70, 0x3a, 0x69, 0x9f, - 0xb8, 0x27, 0xcf, 0x70, 0xeb, 0x9e, 0xbc, 0x28, 0xc4, 0x94, 0xe2, 0x94, 0x6c, 0xbd, 0xcc, 0x7c, - 0xfd, 0xdc, 0xc4, 0x92, 0x0c, 0x3d, 0xcf, 0xbc, 0x92, 0x4b, 0x5b, 0x74, 0xb9, 0xa0, 0xc6, 0x7b, - 0xe6, 0x95, 0x04, 0xf1, 0x94, 0xe4, 0xbb, 0xc0, 0x0d, 0x70, 0xb2, 0x3e, 0xf1, 0x48, 0x8e, 0xf1, - 0xc2, 0x23, 0x39, 0xc6, 0x07, 0x8f, 0xe4, 0x18, 0x27, 0x3c, 0x96, 0x63, 0xb8, 0xf0, 0x58, 0x8e, - 0xe1, 0xc6, 0x63, 0x39, 0x86, 0x28, 0x45, 0x14, 0xc3, 0x2a, 0x50, 0x83, 0x18, 0x1c, 0xbe, 0x49, - 0x6c, 0x60, 0x31, 0x63, 0x40, 0x00, 0x00, 0x00, 0xff, 0xff, 0x1e, 0x8d, 0xab, 0x75, 0xc4, 0x01, - 0x00, 0x00, + // 393 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x92, 0xcf, 0xca, 0xd3, 0x40, + 0x14, 0xc5, 0x33, 0x5f, 0x4b, 0xc0, 0x69, 0x55, 0x08, 0x2a, 0x31, 0x8b, 0xa4, 0x96, 0x22, 0x05, + 0x71, 0x42, 0xab, 0xb8, 0x71, 0x97, 0x8a, 0x52, 0x17, 0x0a, 0xd1, 0x95, 0x9b, 0x92, 0x3f, 0xd3, + 0x18, 0x4c, 0xe6, 0x86, 0xce, 0x4c, 0xd1, 0x47, 0x70, 0xd7, 0x77, 0xd1, 0x87, 0xe8, 0xb2, 0xb8, + 0x12, 0x17, 0x55, 0xda, 0x17, 0x91, 0xce, 0xa4, 0x92, 0x80, 0xdd, 0x7c, 0xbb, 0xc9, 0xbd, 0xbf, + 0x73, 0x72, 0xe0, 0x5c, 0x3c, 0x4a, 0x80, 0x97, 0xc0, 0xfd, 0x6a, 0x05, 0x02, 0x12, 0x28, 0x2a, + 0x80, 0xc2, 0x5f, 0x4f, 0xfc, 0x8c, 0x32, 0xca, 0x73, 0x4e, 0xd4, 0xdc, 0xba, 0xa7, 0x29, 0xd2, + 0xa4, 0xc8, 0x7a, 0xe2, 0x0c, 0x2f, 0xa8, 0xc5, 0x97, 0x8a, 0xd6, 0xb4, 0x73, 0x27, 0x83, 0x0c, + 0xd4, 0xd3, 0x3f, 0xbd, 0xea, 0xe9, 0x7d, 0xad, 0x5c, 0xe8, 0x45, 0xd3, 0xde, 0xf1, 0x32, 0x80, + 0xac, 0xa0, 0xda, 0x34, 0x96, 0x4b, 0x5f, 0xe4, 0x25, 0xe5, 0x22, 0x2a, 0x2b, 0x0d, 0x0c, 0xbf, + 0x5d, 0xe1, 0xfe, 0x2b, 0x9d, 0xef, 0x9d, 0x88, 0x04, 0xb5, 0xde, 0xe2, 0xdb, 0x09, 0x30, 0x91, + 0x33, 0x09, 0x92, 0x2f, 0x96, 0x92, 0xa5, 0x36, 0x1a, 0x74, 0xc6, 0xbd, 0xe9, 0x43, 0xf2, 0xff, + 0xe0, 0x64, 0xf6, 0x0f, 0x7f, 0x29, 0x59, 0x1a, 0xde, 0x4a, 0x5a, 0xdf, 0xd6, 0x33, 0x6c, 0xc6, + 0x32, 0xcd, 0xa8, 0xb0, 0xaf, 0x94, 0x8f, 0x7b, 0xc9, 0x27, 0x50, 0x54, 0x58, 0xd3, 0xd6, 0x1b, + 0xdc, 0x2f, 0x22, 0x2e, 0x16, 0x71, 0x54, 0x44, 0x2c, 0xa1, 0x76, 0x67, 0x80, 0xc6, 0x37, 0x82, + 0x47, 0xdb, 0xbd, 0x67, 0xfc, 0xda, 0x7b, 0x77, 0xb5, 0x09, 0x4f, 0x3f, 0x91, 0x1c, 0xfc, 0x32, + 0x12, 0x1f, 0xc9, 0x9c, 0x89, 0x1f, 0xdf, 0x1f, 0xe3, 0xda, 0x7d, 0xce, 0x44, 0xd8, 0x3b, 0x19, + 0x04, 0x5a, 0x6f, 0xbd, 0xc6, 0x37, 0xd3, 0x9c, 0x8b, 0x55, 0x1e, 0x4b, 0x91, 0x03, 0xe3, 0x76, + 0x57, 0xc5, 0x19, 0x5d, 0x8a, 0xf3, 0xa2, 0x01, 0x87, 0x6d, 0xe9, 0xf0, 0x2b, 0xc2, 0xfd, 0xe6, + 0xde, 0x9a, 0x61, 0x33, 0x2a, 0x41, 0x32, 0x71, 0x9d, 0x98, 0xb5, 0xd4, 0x7a, 0x8a, 0xbb, 0xa7, + 0x7a, 0x6c, 0x73, 0x80, 0xc6, 0xbd, 0xa9, 0x43, 0x74, 0x77, 0xe4, 0xdc, 0x1d, 0x79, 0x7f, 0xee, + 0x2e, 0xe8, 0x6e, 0x7e, 0x7b, 0x28, 0x54, 0x74, 0xf0, 0x7c, 0x7b, 0x70, 0xd1, 0xee, 0xe0, 0xa2, + 0x3f, 0x07, 0x17, 0x6d, 0x8e, 0xae, 0xb1, 0x3b, 0xba, 0xc6, 0xcf, 0xa3, 0x6b, 0x7c, 0x78, 0xd0, + 0xfa, 0xf9, 0xe7, 0xf6, 0x65, 0xa9, 0xb3, 0x8a, 0x4d, 0x35, 0x7b, 0xf2, 0x37, 0x00, 0x00, 0xff, + 0xff, 0x0c, 0x77, 0xdd, 0xf7, 0xbb, 0x02, 0x00, 0x00, } func (m *GenesisState) Marshal() (dAtA []byte, err error) { @@ -132,10 +201,24 @@ func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if len(m.Distributions) > 0 { + for iNdEx := len(m.Distributions) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Distributions[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + } + } { - size := m.ToDistribute.Size() + size := m.LastBalance.Size() i -= size - if _, err := m.ToDistribute.MarshalTo(dAtA[i:]); err != nil { + if _, err := m.LastBalance.MarshalTo(dAtA[i:]); err != nil { return 0, err } i = encodeVarintGenesis(dAtA, i, uint64(size)) @@ -173,6 +256,49 @@ func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *Distribution) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *Distribution) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Distribution) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Time != nil { + n1, err1 := github_com_cosmos_gogoproto_types.StdTimeMarshalTo(*m.Time, dAtA[i-github_com_cosmos_gogoproto_types.SizeOfStdTime(*m.Time):]) + if err1 != nil { + return 0, err1 + } + i -= n1 + i = encodeVarintGenesis(dAtA, i, uint64(n1)) + i-- + dAtA[i] = 0x32 + } + { + size := m.Amount.Size() + i -= size + if _, err := m.Amount.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + return len(dAtA) - i, nil +} + func encodeVarintGenesis(dAtA []byte, offset int, v uint64) int { offset -= sovGenesis(v) base := offset @@ -202,8 +328,29 @@ func (m *GenesisState) Size() (n int) { n += 1 + l + sovGenesis(uint64(l)) } } - l = m.ToDistribute.Size() + l = m.LastBalance.Size() n += 1 + l + sovGenesis(uint64(l)) + if len(m.Distributions) > 0 { + for _, e := range m.Distributions { + l = e.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + } + return n +} + +func (m *Distribution) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.Amount.Size() + n += 1 + l + sovGenesis(uint64(l)) + if m.Time != nil { + l = github_com_cosmos_gogoproto_types.SizeOfStdTime(*m.Time) + n += 1 + l + sovGenesis(uint64(l)) + } return n } @@ -312,7 +459,125 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { iNdEx = postIndex case 3: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ToDistribute", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field LastBalance", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.LastBalance.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Distributions", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Distributions = append(m.Distributions, &Distribution{}) + if err := m.Distributions[len(m.Distributions)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipGenesis(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthGenesis + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *Distribution) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: Distribution: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Distribution: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Amount", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -340,7 +605,43 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if err := m.ToDistribute.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + if err := m.Amount.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Time", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Time == nil { + m.Time = new(time.Time) + } + if err := github_com_cosmos_gogoproto_types.StdTimeUnmarshal(m.Time, dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex diff --git a/x/protocolpool/types/keys.go b/x/protocolpool/types/keys.go index acb721c5edd2..072052937b55 100644 --- a/x/protocolpool/types/keys.go +++ b/x/protocolpool/types/keys.go @@ -9,6 +9,9 @@ const ( // StreamAccount is the name constant used for stream account StreamAccount = "stream_acc" + // ProtocolPoolDistrAccount is an intermediary account that holds the funds to be distributed to the protocolpool accounts. + ProtocolPoolDistrAccount = "protocolpool_distr" + // StoreKey is the store key string for protocolpool StoreKey = ModuleName @@ -26,5 +29,6 @@ var ( ContinuousFundKey = collections.NewPrefix(3) RecipientFundPercentageKey = collections.NewPrefix(4) RecipientFundDistributionKey = collections.NewPrefix(5) - ToDistributeKey = collections.NewPrefix(6) + DistributionsKey = collections.NewPrefix(6) + LastBalanceKey = collections.NewPrefix(7) ) From d514f339d15fd1ca8bbccb66a4786fc558829087 Mon Sep 17 00:00:00 2001 From: Marko Date: Thu, 25 Jul 2024 08:22:27 +0200 Subject: [PATCH 43/50] chore: add test for account creation (#21053) --- tests/systemtests/README.md | 8 ++++- tests/systemtests/account_test.go | 50 +++++++++++++++++++++++++++++++ 2 files changed, 57 insertions(+), 1 deletion(-) create mode 100644 tests/systemtests/account_test.go diff --git a/tests/systemtests/README.md b/tests/systemtests/README.md index ab20d155f08f..61eaf89d0223 100644 --- a/tests/systemtests/README.md +++ b/tests/systemtests/README.md @@ -3,19 +3,23 @@ Test framework for system tests. Starts and interacts with a (multi node) blockchain in Go. Supports + * CLI * Servers * Events * RPC Uses: + * testify * gjson * sjson Server and client side are executed on the host machine ## Developer + ### Test strategy + System tests cover the full stack via cli and a running (multi node) network. They are more expensive (in terms of time/ cpu) to run compared to unit or integration tests. Therefore, we focus on the **critical path** and do not cover every condition. @@ -33,7 +37,9 @@ Test cli parameters * `-nodes-count` int - number of nodes in the cluster (default 4) # Port ranges + With *n* nodes: + * `26657` - `26657+n` - RPC * `1317` - `1317+n` - API * `9090` - `9090+n` - GRPC @@ -47,4 +53,4 @@ For example Node *3* listens on `26660` for RPC calls ## Disclaimer -This is based on the system test framework in [wasmd](https://github.com/CosmWasm/wasmd) built by Confio. \ No newline at end of file +This is based on the system test framework in [wasmd](https://github.com/CosmWasm/wasmd) built by Confio. diff --git a/tests/systemtests/account_test.go b/tests/systemtests/account_test.go new file mode 100644 index 000000000000..c3940579e2c3 --- /dev/null +++ b/tests/systemtests/account_test.go @@ -0,0 +1,50 @@ +package systemtests + +import ( + "strings" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/tidwall/gjson" +) + +func TestAccountCreation(t *testing.T) { + // scenario: test account creation + // given a running chain + // when accountA is sending funds to accountB, + // AccountB should not be created + // when accountB is sending funds to accountA, + // AccountB should be created + + sut.ResetChain(t) + cli := NewCLIWrapper(t, sut, verbose) + // add genesis account with some tokens + account1Addr := cli.AddKey("account1") + account2Addr := cli.AddKey("account2") + sut.ModifyGenesisCLI(t, + []string{"genesis", "add-genesis-account", account1Addr, "10000000stake"}, + ) + + sut.StartChain(t) + + // query account1 + rsp := cli.CustomQuery("q", "auth", "account", account1Addr) + assert.Equal(t, account1Addr, gjson.Get(rsp, "account.value.address").String(), rsp) + + rsp1 := cli.Run("tx", "bank", "send", account1Addr, account2Addr, "5000stake", "--from="+account1Addr, "--fees=1stake") + RequireTxSuccess(t, rsp1) + + // query account2 + + rsp2 := cli.WithRunErrorsIgnored().CustomQuery("q", "auth", "account", account2Addr) + assert.True(t, strings.Contains(rsp2, "not found: key not found")) + + rsp3 := cli.Run("tx", "bank", "send", account2Addr, account1Addr, "1000stake", "--from="+account1Addr, "--fees=1stake") + RequireTxSuccess(t, rsp3) + + // query account2 to make sure its created + rsp4 := cli.CustomQuery("q", "auth", "account", account2Addr) + assert.Equal(t, "1", gjson.Get(rsp4, "account.value.sequence").String(), rsp4) + rsp5 := cli.CustomQuery("q", "auth", "account", account1Addr) + assert.Equal(t, "1", gjson.Get(rsp5, "account.value.sequence").String(), rsp5) +} From 6a2d039e1212b0b709a17cf514453e4fe505dad9 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 25 Jul 2024 09:28:23 +0200 Subject: [PATCH 44/50] build(deps): Bump bufbuild/buf-setup-action from 1.35.0 to 1.35.1 (#21063) Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/proto.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/proto.yml b/.github/workflows/proto.yml index 3302e6edc82d..d11a355bc546 100644 --- a/.github/workflows/proto.yml +++ b/.github/workflows/proto.yml @@ -15,7 +15,7 @@ jobs: timeout-minutes: 5 steps: - uses: actions/checkout@v4 - - uses: bufbuild/buf-setup-action@v1.35.0 + - uses: bufbuild/buf-setup-action@v1.35.1 - uses: bufbuild/buf-lint-action@v1 with: input: "proto" @@ -24,7 +24,7 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - uses: bufbuild/buf-setup-action@v1.35.0 + - uses: bufbuild/buf-setup-action@v1.35.1 - uses: bufbuild/buf-breaking-action@v1 with: input: "proto" From d6ad92db0f5b9051cddc9944ca93d2e8f39d1d43 Mon Sep 17 00:00:00 2001 From: yukionfire Date: Thu, 25 Jul 2024 20:54:49 +0800 Subject: [PATCH 45/50] chore(all): replace all `fmt.Errorf` without paramters with `errors.New` (#21068) --- baseapp/grpcrouter_helpers.go | 3 ++- client/cmd.go | 2 +- client/grpc_query.go | 4 ++-- client/snapshot/load.go | 4 ++-- client/tx/factory.go | 2 +- client/tx/tx_test.go | 3 ++- client/v2/autocli/flag/coin.go | 4 ++-- client/v2/internal/coins/format.go | 6 +++--- client/v2/internal/prompt/validation.go | 3 ++- client/v2/offchain/verify.go | 2 +- collections/iter_test.go | 3 ++- collections/map_test.go | 4 ++-- depinject/appconfig/config.go | 3 ++- depinject/container_test.go | 5 +++-- depinject/internal/codegen/file.go | 4 ++-- indexer/postgres/indexer.go | 3 ++- internal/testutil/cmd_test.go | 3 ++- orm/encoding/ormfield/uint32.go | 4 ++-- orm/encoding/ormfield/uint64.go | 4 ++-- orm/internal/listinternal/options.go | 4 ++-- orm/model/ormdb/module.go | 5 +++-- orm/model/ormdb/module_test.go | 6 +++--- orm/model/ormtable/backend.go | 3 ++- orm/model/ormtable/bench_test.go | 5 +++-- runtime/branch_test.go | 6 +++--- runtime/v2/manager.go | 2 +- schema/decoding/decoding_test.go | 3 ++- server/cmt_cmds.go | 5 +++-- server/grpc/reflection/v2alpha1/reflection.go | 2 +- server/v2/api/telemetry/metrics.go | 5 +++-- server/v2/appmanager/appmanager.go | 3 ++- server/v2/cometbft/abci.go | 4 ++-- server/v2/cometbft/commands.go | 5 +++-- server/v2/cometbft/handlers/defaults.go | 2 +- server/v2/cometbft/utils.go | 3 ++- server/v2/stf/core_branch_service_test.go | 4 ++-- server/v2/stf/stf_test.go | 12 ++++++------ store/v2/commitment/store.go | 4 ++-- store/v2/migration/manager.go | 2 +- tests/integration/example/example_test.go | 5 +++-- testutil/network/network.go | 10 +++++----- testutil/sims/address_helpers.go | 4 ++-- testutil/sims/app_helpers.go | 3 ++- testutil/sims/state_helpers.go | 4 ++-- testutil/testdata/grpc_query.go | 3 ++- tools/cosmovisor/args.go | 2 +- tools/hubl/internal/version.go | 4 ++-- types/collections.go | 3 ++- types/mempool/mempool_test.go | 3 ++- types/mempool/priority_nonce.go | 7 ++++--- types/mempool/sender_nonce.go | 6 +++--- types/mempool/signer_extraction_adapater_test.go | 5 +++-- types/query/collections_pagination.go | 3 +-- types/query/filtered_pagination.go | 6 +++--- types/query/pagination.go | 4 ++-- types/simulation/account.go | 4 ++-- x/protocolpool/keeper/genesis.go | 3 ++- 57 files changed, 127 insertions(+), 103 deletions(-) diff --git a/baseapp/grpcrouter_helpers.go b/baseapp/grpcrouter_helpers.go index e629be06cb63..907cef764a86 100644 --- a/baseapp/grpcrouter_helpers.go +++ b/baseapp/grpcrouter_helpers.go @@ -2,6 +2,7 @@ package baseapp import ( gocontext "context" + "errors" "fmt" abci "github.com/cometbft/cometbft/api/cometbft/abci/v1" @@ -60,5 +61,5 @@ func (q *QueryServiceTestHelper) Invoke(_ gocontext.Context, method string, args // NewStream implements the grpc ClientConn.NewStream method func (q *QueryServiceTestHelper) NewStream(gocontext.Context, *grpc.StreamDesc, string, ...grpc.CallOption) (grpc.ClientStream, error) { - return nil, fmt.Errorf("not supported") + return nil, errors.New("not supported") } diff --git a/client/cmd.go b/client/cmd.go index c5b40774d9e4..7ea1f49e0942 100644 --- a/client/cmd.go +++ b/client/cmd.go @@ -290,7 +290,7 @@ func readTxCommandFlags(clientCtx Context, flagSet *pflag.FlagSet) (Context, err if keyType == keyring.TypeLedger && clientCtx.SignModeStr == flags.SignModeTextual { if !slices.Contains(clientCtx.TxConfig.SignModeHandler().SupportedModes(), signingv1beta1.SignMode_SIGN_MODE_TEXTUAL) { - return clientCtx, fmt.Errorf("SIGN_MODE_TEXTUAL is not available") + return clientCtx, errors.New("SIGN_MODE_TEXTUAL is not available") } } diff --git a/client/grpc_query.go b/client/grpc_query.go index 45f60e48d2de..df6ac284f434 100644 --- a/client/grpc_query.go +++ b/client/grpc_query.go @@ -2,7 +2,7 @@ package client import ( gocontext "context" - "fmt" + "errors" "reflect" "strconv" @@ -123,7 +123,7 @@ func (ctx Context) Invoke(grpcCtx gocontext.Context, method string, req, reply i // NewStream implements the grpc ClientConn.NewStream method func (Context) NewStream(gocontext.Context, *grpc.StreamDesc, string, ...grpc.CallOption) (grpc.ClientStream, error) { - return nil, fmt.Errorf("streaming rpc not supported") + return nil, errors.New("streaming rpc not supported") } // gRPCCodec checks if Context's Codec is codec.GRPCCodecProvider diff --git a/client/snapshot/load.go b/client/snapshot/load.go index b64f2eac860d..657929b44104 100644 --- a/client/snapshot/load.go +++ b/client/snapshot/load.go @@ -102,12 +102,12 @@ func LoadArchiveCmd() *cobra.Command { savedSnapshot := <-quitChan if savedSnapshot == nil { - return fmt.Errorf("failed to save snapshot") + return errors.New("failed to save snapshot") } if !reflect.DeepEqual(&snapshot, savedSnapshot) { _ = snapshotStore.Delete(snapshot.Height, snapshot.Format) - return fmt.Errorf("invalid archive, the saved snapshot is not equal to the original one") + return errors.New("invalid archive, the saved snapshot is not equal to the original one") } return nil diff --git a/client/tx/factory.go b/client/tx/factory.go index 598d389d5f40..625fa975b2f3 100644 --- a/client/tx/factory.go +++ b/client/tx/factory.go @@ -441,7 +441,7 @@ func (f Factory) BuildSimTx(msgs ...sdk.Msg) ([]byte, error) { encoder := f.txConfig.TxEncoder() if encoder == nil { - return nil, fmt.Errorf("cannot simulate tx: tx encoder is nil") + return nil, errors.New("cannot simulate tx: tx encoder is nil") } return encoder(txb.GetTx()) diff --git a/client/tx/tx_test.go b/client/tx/tx_test.go index 77cd0401e520..fd81ee79e26d 100644 --- a/client/tx/tx_test.go +++ b/client/tx/tx_test.go @@ -2,6 +2,7 @@ package tx import ( "context" + "errors" "fmt" "strings" "testing" @@ -44,7 +45,7 @@ type mockContext struct { func (m mockContext) Invoke(_ context.Context, _ string, _, reply interface{}, _ ...grpc.CallOption) (err error) { if m.wantErr { - return fmt.Errorf("mock err") + return errors.New("mock err") } *(reply.(*txtypes.SimulateResponse)) = txtypes.SimulateResponse{ diff --git a/client/v2/autocli/flag/coin.go b/client/v2/autocli/flag/coin.go index 6ed842a34a93..f317d8585776 100644 --- a/client/v2/autocli/flag/coin.go +++ b/client/v2/autocli/flag/coin.go @@ -2,7 +2,7 @@ package flag import ( "context" - "fmt" + "errors" "strings" "google.golang.org/protobuf/reflect/protoreflect" @@ -38,7 +38,7 @@ func (c *coinValue) String() string { func (c *coinValue) Set(stringValue string) error { if strings.Contains(stringValue, ",") { - return fmt.Errorf("coin flag must be a single coin, specific multiple coins with multiple flags or spaces") + return errors.New("coin flag must be a single coin, specific multiple coins with multiple flags or spaces") } coin, err := coins.ParseCoin(stringValue) diff --git a/client/v2/internal/coins/format.go b/client/v2/internal/coins/format.go index 1c84fe9beab9..c447040c2456 100644 --- a/client/v2/internal/coins/format.go +++ b/client/v2/internal/coins/format.go @@ -1,7 +1,7 @@ package coins import ( - "fmt" + "errors" "regexp" "strings" @@ -19,13 +19,13 @@ func ParseCoin(input string) (*basev1beta1.Coin, error) { input = strings.TrimSpace(input) if input == "" { - return nil, fmt.Errorf("empty input when parsing coin") + return nil, errors.New("empty input when parsing coin") } matches := coinRegex.FindStringSubmatch(input) if len(matches) == 0 { - return nil, fmt.Errorf("invalid input format") + return nil, errors.New("invalid input format") } return &basev1beta1.Coin{ diff --git a/client/v2/internal/prompt/validation.go b/client/v2/internal/prompt/validation.go index 8a6e5a2d334f..d914999f214d 100644 --- a/client/v2/internal/prompt/validation.go +++ b/client/v2/internal/prompt/validation.go @@ -1,6 +1,7 @@ package prompt import ( + "errors" "fmt" "net/url" @@ -10,7 +11,7 @@ import ( // ValidatePromptNotEmpty validates that the input is not empty. func ValidatePromptNotEmpty(input string) error { if input == "" { - return fmt.Errorf("input cannot be empty") + return errors.New("input cannot be empty") } return nil diff --git a/client/v2/offchain/verify.go b/client/v2/offchain/verify.go index 303a086022a7..8b9580d63235 100644 --- a/client/v2/offchain/verify.go +++ b/client/v2/offchain/verify.go @@ -123,7 +123,7 @@ func verifySignature( return err } if !pubKey.VerifySignature(signBytes, data.Signature) { - return fmt.Errorf("unable to verify single signer signature") + return errors.New("unable to verify single signer signature") } return nil default: diff --git a/collections/iter_test.go b/collections/iter_test.go index e18bad20a864..872156196900 100644 --- a/collections/iter_test.go +++ b/collections/iter_test.go @@ -1,6 +1,7 @@ package collections import ( + "errors" "fmt" "testing" @@ -188,7 +189,7 @@ func TestWalk(t *testing.T) { }) require.NoError(t, err) - sentinelErr := fmt.Errorf("sentinel error") + sentinelErr := errors.New("sentinel error") err = m.Walk(ctx, nil, func(key, value uint64) (stop bool, err error) { require.LessOrEqual(t, key, uint64(3)) // asserts that after the number three we stop if key == 3 { diff --git a/collections/map_test.go b/collections/map_test.go index f95935c5720e..5f1ae176df07 100644 --- a/collections/map_test.go +++ b/collections/map_test.go @@ -2,7 +2,7 @@ package collections import ( "context" - "fmt" + "errors" "testing" "github.com/stretchr/testify/require" @@ -53,7 +53,7 @@ func TestMap_Clear(t *testing.T) { err := m.Clear(ctx, nil) require.NoError(t, err) err = m.Walk(ctx, nil, func(key, value uint64) (bool, error) { - return false, fmt.Errorf("should never be called") + return false, errors.New("should never be called") }) require.NoError(t, err) }) diff --git a/depinject/appconfig/config.go b/depinject/appconfig/config.go index 10e1d037386d..9bffeae41c50 100644 --- a/depinject/appconfig/config.go +++ b/depinject/appconfig/config.go @@ -1,6 +1,7 @@ package appconfig import ( + "errors" "fmt" "reflect" "strings" @@ -95,7 +96,7 @@ func Compose(appConfig gogoproto.Message) depinject.Config { for _, module := range appConfigConcrete.Modules { if module.Name == "" { - return depinject.Error(fmt.Errorf("module is missing name")) + return depinject.Error(errors.New("module is missing name")) } if module.Config == nil { diff --git a/depinject/container_test.go b/depinject/container_test.go index 43010004cc35..dc4a9291e370 100644 --- a/depinject/container_test.go +++ b/depinject/container_test.go @@ -1,6 +1,7 @@ package depinject_test import ( + "errors" "fmt" "os" "testing" @@ -300,7 +301,7 @@ func TestCyclic(t *testing.T) { } func TestErrorOption(t *testing.T) { - err := depinject.Inject(depinject.Error(fmt.Errorf("an error"))) + err := depinject.Inject(depinject.Error(errors.New("an error"))) require.Error(t, err) } @@ -606,7 +607,7 @@ func ProvideTestOutput() (TestOutput, error) { } func ProvideTestOutputErr() (TestOutput, error) { - return TestOutput{}, fmt.Errorf("error") + return TestOutput{}, errors.New("error") } func TestStructArgs(t *testing.T) { diff --git a/depinject/internal/codegen/file.go b/depinject/internal/codegen/file.go index dba77becb13e..09a1a6109637 100644 --- a/depinject/internal/codegen/file.go +++ b/depinject/internal/codegen/file.go @@ -1,7 +1,7 @@ package codegen import ( - "fmt" + "errors" "go/ast" "go/token" "strconv" @@ -61,7 +61,7 @@ func NewFileGen(file *ast.File, codegenPkgPath string) (*FileGen, error) { if spec.Name != nil { name := spec.Name.Name if name == "." { - return nil, fmt.Errorf(". package imports are not allowed") + return nil, errors.New(". package imports are not allowed") } info = &importInfo{importPrefix: name, ImportSpec: spec} diff --git a/indexer/postgres/indexer.go b/indexer/postgres/indexer.go index afcd8e0d8dbf..a69eefff1cd0 100644 --- a/indexer/postgres/indexer.go +++ b/indexer/postgres/indexer.go @@ -3,6 +3,7 @@ package postgres import ( "context" "database/sql" + "errors" "fmt" "cosmossdk.io/schema/appdata" @@ -23,7 +24,7 @@ type SqlLogger = func(msg, sql string, params ...interface{}) func StartIndexer(ctx context.Context, logger SqlLogger, config Config) (appdata.Listener, error) { if config.DatabaseURL == "" { - return appdata.Listener{}, fmt.Errorf("missing database URL") + return appdata.Listener{}, errors.New("missing database URL") } driver := config.DatabaseDriver diff --git a/internal/testutil/cmd_test.go b/internal/testutil/cmd_test.go index 2544b2467c44..4151360b9a0d 100644 --- a/internal/testutil/cmd_test.go +++ b/internal/testutil/cmd_test.go @@ -1,6 +1,7 @@ package testutil_test import ( + "errors" "fmt" "testing" @@ -21,7 +22,7 @@ func TestSetArgsWithOriginalMethod(t *testing.T) { c, _ := cmd.Flags().GetBool("c") switch { case a && b, a && c, b && c: - return fmt.Errorf("a,b,c only one could be true") + return errors.New("a,b,c only one could be true") } return nil }, diff --git a/orm/encoding/ormfield/uint32.go b/orm/encoding/ormfield/uint32.go index 0e770ad6b482..0da31691d9f6 100644 --- a/orm/encoding/ormfield/uint32.go +++ b/orm/encoding/ormfield/uint32.go @@ -2,7 +2,7 @@ package ormfield import ( "encoding/binary" - "fmt" + "errors" "io" "google.golang.org/protobuf/reflect/protoreflect" @@ -183,6 +183,6 @@ func DecodeCompactUint32(reader io.Reader) (uint32, error) { x |= uint32(buf[4]) return x, nil default: - return 0, fmt.Errorf("unexpected case") + return 0, errors.New("unexpected case") } } diff --git a/orm/encoding/ormfield/uint64.go b/orm/encoding/ormfield/uint64.go index 8623e516b155..43f08b0302c4 100644 --- a/orm/encoding/ormfield/uint64.go +++ b/orm/encoding/ormfield/uint64.go @@ -2,7 +2,7 @@ package ormfield import ( "encoding/binary" - "fmt" + "errors" "io" "google.golang.org/protobuf/reflect/protoreflect" @@ -213,6 +213,6 @@ func DecodeCompactUint64(reader io.Reader) (uint64, error) { x |= uint64(buf[8]) return x, nil default: - return 0, fmt.Errorf("unexpected case") + return 0, errors.New("unexpected case") } } diff --git a/orm/internal/listinternal/options.go b/orm/internal/listinternal/options.go index fb5c254dc88d..45571b24af1d 100644 --- a/orm/internal/listinternal/options.go +++ b/orm/internal/listinternal/options.go @@ -1,7 +1,7 @@ package listinternal import ( - "fmt" + "errors" "google.golang.org/protobuf/proto" ) @@ -17,7 +17,7 @@ type Options struct { func (o Options) Validate() error { if len(o.Cursor) != 0 { if o.Offset > 0 { - return fmt.Errorf("can only specify one of cursor or offset") + return errors.New("can only specify one of cursor or offset") } } return nil diff --git a/orm/model/ormdb/module.go b/orm/model/ormdb/module.go index 35d264196a3e..5aebb7a02339 100644 --- a/orm/model/ormdb/module.go +++ b/orm/model/ormdb/module.go @@ -4,6 +4,7 @@ import ( "bytes" "context" "encoding/binary" + "errors" "fmt" "math" @@ -111,7 +112,7 @@ func NewModuleDB(schema *ormv1alpha1.ModuleSchemaDescriptor, options ModuleDBOpt case ormv1alpha1.StorageType_STORAGE_TYPE_MEMORY: service := options.MemoryStoreService if service == nil { - return nil, fmt.Errorf("missing MemoryStoreService") + return nil, errors.New("missing MemoryStoreService") } backendResolver = func(ctx context.Context) (ormtable.ReadBackend, error) { @@ -124,7 +125,7 @@ func NewModuleDB(schema *ormv1alpha1.ModuleSchemaDescriptor, options ModuleDBOpt case ormv1alpha1.StorageType_STORAGE_TYPE_TRANSIENT: service := options.TransientStoreService if service == nil { - return nil, fmt.Errorf("missing TransientStoreService") + return nil, errors.New("missing TransientStoreService") } backendResolver = func(ctx context.Context) (ormtable.ReadBackend, error) { diff --git a/orm/model/ormdb/module_test.go b/orm/model/ormdb/module_test.go index 2557cd857c96..4127a0b88bfe 100644 --- a/orm/model/ormdb/module_test.go +++ b/orm/model/ormdb/module_test.go @@ -4,7 +4,7 @@ import ( "bytes" "context" "encoding/json" - "fmt" + "errors" "strings" "testing" @@ -103,7 +103,7 @@ func (k keeper) Burn(ctx context.Context, acct, denom string, amount uint64) err } if amount > supply.Amount { - return fmt.Errorf("insufficient supply") + return errors.New("insufficient supply") } supply.Amount -= amount @@ -171,7 +171,7 @@ func (k keeper) safeSubBalance(ctx context.Context, acct, denom string, amount u } if amount > balance.Amount { - return fmt.Errorf("insufficient funds") + return errors.New("insufficient funds") } balance.Amount -= amount diff --git a/orm/model/ormtable/backend.go b/orm/model/ormtable/backend.go index 2c1f234187ff..adeccc87188c 100644 --- a/orm/model/ormtable/backend.go +++ b/orm/model/ormtable/backend.go @@ -2,6 +2,7 @@ package ormtable import ( "context" + "errors" "fmt" "cosmossdk.io/core/store" @@ -182,7 +183,7 @@ var defaultContextKey = contextKeyType("backend") func getBackendDefault(ctx context.Context) (ReadBackend, error) { value := ctx.Value(defaultContextKey) if value == nil { - return nil, fmt.Errorf("can't resolve backend") + return nil, errors.New("can't resolve backend") } backend, ok := value.(ReadBackend) diff --git a/orm/model/ormtable/bench_test.go b/orm/model/ormtable/bench_test.go index 337e049fb26a..450d54e2af92 100644 --- a/orm/model/ormtable/bench_test.go +++ b/orm/model/ormtable/bench_test.go @@ -2,6 +2,7 @@ package ormtable_test import ( "context" + "errors" "fmt" "testing" @@ -143,7 +144,7 @@ func insertBalance(store kv.Store, balance *testpb.Balance) error { } if has { - return fmt.Errorf("already exists") + return errors.New("already exists") } bz, err := proto.Marshal(balance) @@ -223,7 +224,7 @@ func getBalance(store kv.Store, address, denom string) (*testpb.Balance, error) } if bz == nil { - return nil, fmt.Errorf("not found") + return nil, errors.New("not found") } balance := testpb.Balance{} diff --git a/runtime/branch_test.go b/runtime/branch_test.go index 29a6c9703e0b..bd0dc1154a15 100644 --- a/runtime/branch_test.go +++ b/runtime/branch_test.go @@ -2,7 +2,7 @@ package runtime import ( "context" - "fmt" + "errors" "testing" "github.com/stretchr/testify/require" @@ -52,7 +52,7 @@ func TestBranchService(t *testing.T) { ctx := testutil.DefaultContext(sk, tsk) err := bs.Execute(ctx, func(ctx context.Context) error { doStateChange(ctx) - return fmt.Errorf("failure") + return errors.New("failure") }) require.Error(t, err) assertRollback(ctx, true) @@ -76,7 +76,7 @@ func TestBranchService(t *testing.T) { ctx := testutil.DefaultContext(sk, tsk) gasUsed, err := bs.ExecuteWithGasLimit(ctx, 4_000, func(ctx context.Context) error { doStateChange(ctx) - return fmt.Errorf("failure") + return errors.New("failure") }) require.Error(t, err) // assert gas used diff --git a/runtime/v2/manager.go b/runtime/v2/manager.go index c947e0b96581..c64423ee9e20 100644 --- a/runtime/v2/manager.go +++ b/runtime/v2/manager.go @@ -410,7 +410,7 @@ func (m *MM[T]) RunMigrations(ctx context.Context, fromVM appmodulev2.VersionMap // The module manager assumes only one module will update the validator set, and it can't be a new module. if len(moduleValUpdates) > 0 { - return nil, fmt.Errorf("validator InitGenesis update is already set by another module") + return nil, errors.New("validator InitGenesis update is already set by another module") } } } diff --git a/schema/decoding/decoding_test.go b/schema/decoding/decoding_test.go index 5f6872af593a..a671d2f4c35b 100644 --- a/schema/decoding/decoding_test.go +++ b/schema/decoding/decoding_test.go @@ -1,6 +1,7 @@ package decoding import ( + "errors" "fmt" "reflect" "sort" @@ -360,7 +361,7 @@ func (e exampleBankModule) subBalance(acct, denom string, amount uint64) error { key := balanceKey(acct, denom) cur := e.store.GetUInt64(key) if cur < amount { - return fmt.Errorf("insufficient balance") + return errors.New("insufficient balance") } e.store.SetUInt64(key, cur-amount) return nil diff --git a/server/cmt_cmds.go b/server/cmt_cmds.go index e4fdf1ed814c..1d2eb70b04c7 100644 --- a/server/cmt_cmds.go +++ b/server/cmt_cmds.go @@ -3,6 +3,7 @@ package server import ( "context" "encoding/json" + "errors" "fmt" "strconv" "strings" @@ -239,7 +240,7 @@ $ %s query block --%s=%s case auth.TypeHeight: if args[0] == "" { - return fmt.Errorf("argument should be a block height") + return errors.New("argument should be a block height") } // optional height @@ -265,7 +266,7 @@ $ %s query block --%s=%s case auth.TypeHash: if args[0] == "" { - return fmt.Errorf("argument should be a tx hash") + return errors.New("argument should be a tx hash") } // If hash is given, then query the tx by hash. diff --git a/server/grpc/reflection/v2alpha1/reflection.go b/server/grpc/reflection/v2alpha1/reflection.go index 2e2fd1a45e6a..fd1ffe4293f7 100644 --- a/server/grpc/reflection/v2alpha1/reflection.go +++ b/server/grpc/reflection/v2alpha1/reflection.go @@ -162,7 +162,7 @@ func newTxDescriptor(ir codectypes.InterfaceRegistry) (*TxDescriptor, error) { // get base tx type name txPbName := proto.MessageName(&tx.Tx{}) if txPbName == "" { - return nil, fmt.Errorf("unable to get *tx.Tx protobuf name") + return nil, errors.New("unable to get *tx.Tx protobuf name") } // get msgs sdkMsgImplementers := ir.ListImplementations(sdk.MsgInterfaceProtoName) diff --git a/server/v2/api/telemetry/metrics.go b/server/v2/api/telemetry/metrics.go index 78fe6388ca68..39055af6739b 100644 --- a/server/v2/api/telemetry/metrics.go +++ b/server/v2/api/telemetry/metrics.go @@ -3,6 +3,7 @@ package telemetry import ( "bytes" "encoding/json" + "errors" "fmt" "net/http" "time" @@ -145,7 +146,7 @@ func (m *Metrics) Gather(format string) (GatherResponse, error) { // If Prometheus metrics are not enabled, it returns an error. func (m *Metrics) gatherPrometheus() (GatherResponse, error) { if !m.prometheusEnabled { - return GatherResponse{}, fmt.Errorf("prometheus metrics are not enabled") + return GatherResponse{}, errors.New("prometheus metrics are not enabled") } metricsFamilies, err := prometheus.DefaultGatherer.Gather() @@ -171,7 +172,7 @@ func (m *Metrics) gatherPrometheus() (GatherResponse, error) { func (m *Metrics) gatherGeneric() (GatherResponse, error) { gm, ok := m.sink.(DisplayableSink) if !ok { - return GatherResponse{}, fmt.Errorf("non in-memory metrics sink does not support generic format") + return GatherResponse{}, errors.New("non in-memory metrics sink does not support generic format") } summary, err := gm.DisplayMetrics(nil, nil) diff --git a/server/v2/appmanager/appmanager.go b/server/v2/appmanager/appmanager.go index d9c84c5035d7..cef0fc57cce7 100644 --- a/server/v2/appmanager/appmanager.go +++ b/server/v2/appmanager/appmanager.go @@ -4,6 +4,7 @@ import ( "bytes" "context" "encoding/json" + "errors" "fmt" appmanager "cosmossdk.io/core/app" @@ -46,7 +47,7 @@ func (a AppManager[T]) InitGenesis( return nil, nil, fmt.Errorf("unable to get latest state: %w", err) } if v != 0 { // TODO: genesis state may be > 0, we need to set version on store - return nil, nil, fmt.Errorf("cannot init genesis on non-zero state") + return nil, nil, errors.New("cannot init genesis on non-zero state") } var genTxs []T diff --git a/server/v2/cometbft/abci.go b/server/v2/cometbft/abci.go index b0c1a8452a13..c83360ed75d6 100644 --- a/server/v2/cometbft/abci.go +++ b/server/v2/cometbft/abci.go @@ -543,7 +543,7 @@ func (c *Consensus[T]) VerifyVoteExtension( } if c.verifyVoteExt == nil { - return nil, fmt.Errorf("vote extensions are enabled but no verify function was set") + return nil, errors.New("vote extensions are enabled but no verify function was set") } _, latestStore, err := c.store.StateLatest() @@ -579,7 +579,7 @@ func (c *Consensus[T]) ExtendVote(ctx context.Context, req *abciproto.ExtendVote } if c.verifyVoteExt == nil { - return nil, fmt.Errorf("vote extensions are enabled but no verify function was set") + return nil, errors.New("vote extensions are enabled but no verify function was set") } _, latestStore, err := c.store.StateLatest() diff --git a/server/v2/cometbft/commands.go b/server/v2/cometbft/commands.go index 16c1e30905eb..26d13058952a 100644 --- a/server/v2/cometbft/commands.go +++ b/server/v2/cometbft/commands.go @@ -2,6 +2,7 @@ package cometbft import ( "encoding/json" + "errors" "fmt" "strconv" "strings" @@ -253,7 +254,7 @@ $ %s query block --%s=%s switch typ { case TypeHeight: if args[0] == "" { - return fmt.Errorf("argument should be a block height") + return errors.New("argument should be a block height") } // optional height @@ -284,7 +285,7 @@ $ %s query block --%s=%s case TypeHash: if args[0] == "" { - return fmt.Errorf("argument should be a tx hash") + return errors.New("argument should be a tx hash") } // If hash is given, then query the tx by hash. diff --git a/server/v2/cometbft/handlers/defaults.go b/server/v2/cometbft/handlers/defaults.go index f7e32f64fa45..c16064974b1f 100644 --- a/server/v2/cometbft/handlers/defaults.go +++ b/server/v2/cometbft/handlers/defaults.go @@ -140,7 +140,7 @@ func (h *DefaultProposalHandler[T]) ProcessHandler() ProcessHandler[T] { if maxBlockGas > 0 { gaslimit, err := tx.GetGasLimit() if err != nil { - return fmt.Errorf("failed to get gas limit") + return errors.New("failed to get gas limit") } totalTxGas += gaslimit if totalTxGas > maxBlockGas { diff --git a/server/v2/cometbft/utils.go b/server/v2/cometbft/utils.go index b4bfb5a6dd30..7f513fb3e6fb 100644 --- a/server/v2/cometbft/utils.go +++ b/server/v2/cometbft/utils.go @@ -2,6 +2,7 @@ package cometbft import ( "context" + "errors" "fmt" "math" "strings" @@ -296,7 +297,7 @@ func (c *Consensus[T]) GetConsensusParams(ctx context.Context) (*cmtproto.Consen } if r, ok := res.(*consensus.QueryParamsResponse); !ok { - return nil, fmt.Errorf("failed to query consensus params") + return nil, errors.New("failed to query consensus params") } else { // convert our params to cometbft params evidenceMaxDuration := r.Params.Evidence.MaxAgeDuration diff --git a/server/v2/stf/core_branch_service_test.go b/server/v2/stf/core_branch_service_test.go index 960563faba0d..21854001ba56 100644 --- a/server/v2/stf/core_branch_service_test.go +++ b/server/v2/stf/core_branch_service_test.go @@ -2,7 +2,7 @@ package stf import ( "context" - "fmt" + "errors" "testing" gogotypes "github.com/cosmos/gogoproto/types" @@ -70,7 +70,7 @@ func TestBranchService(t *testing.T) { stfCtx := makeContext() gasUsed, err := branchService.ExecuteWithGasLimit(stfCtx, 10000, func(ctx context.Context) error { kvSet(t, ctx, "cookies") - return fmt.Errorf("fail") + return errors.New("fail") }) require.Error(t, err) require.NotZero(t, gasUsed) diff --git a/server/v2/stf/stf_test.go b/server/v2/stf/stf_test.go index a77c126087ee..6d6fc692a30b 100644 --- a/server/v2/stf/stf_test.go +++ b/server/v2/stf/stf_test.go @@ -3,7 +3,7 @@ package stf import ( "context" "crypto/sha256" - "fmt" + "errors" "testing" "time" @@ -158,7 +158,7 @@ func TestSTF(t *testing.T) { // update the stf to fail on the handler s := s.clone() addMsgHandlerToSTF(t, &s, func(ctx context.Context, msg *gogotypes.BoolValue) (*gogotypes.BoolValue, error) { - return nil, fmt.Errorf("failure") + return nil, errors.New("failure") }) blockResult, newState, err := s.DeliverBlock(context.Background(), &appmanager.BlockRequest[mock.Tx]{ @@ -180,7 +180,7 @@ func TestSTF(t *testing.T) { t.Run("tx is success but post tx failed", func(t *testing.T) { s := s.clone() s.postTxExec = func(ctx context.Context, tx mock.Tx, success bool) error { - return fmt.Errorf("post tx failure") + return errors.New("post tx failure") } blockResult, newState, err := s.DeliverBlock(context.Background(), &appmanager.BlockRequest[mock.Tx]{ Height: uint64(1), @@ -201,9 +201,9 @@ func TestSTF(t *testing.T) { t.Run("tx failed and post tx failed", func(t *testing.T) { s := s.clone() addMsgHandlerToSTF(t, &s, func(ctx context.Context, msg *gogotypes.BoolValue) (*gogotypes.BoolValue, error) { - return nil, fmt.Errorf("exec failure") + return nil, errors.New("exec failure") }) - s.postTxExec = func(ctx context.Context, tx mock.Tx, success bool) error { return fmt.Errorf("post tx failure") } + s.postTxExec = func(ctx context.Context, tx mock.Tx, success bool) error { return errors.New("post tx failure") } blockResult, newState, err := s.DeliverBlock(context.Background(), &appmanager.BlockRequest[mock.Tx]{ Height: uint64(1), Time: time.Date(2024, 2, 3, 18, 23, 0, 0, time.UTC), @@ -223,7 +223,7 @@ func TestSTF(t *testing.T) { t.Run("fail validate tx", func(t *testing.T) { // update stf to fail on the validation step s := s.clone() - s.doTxValidation = func(ctx context.Context, tx mock.Tx) error { return fmt.Errorf("failure") } + s.doTxValidation = func(ctx context.Context, tx mock.Tx) error { return errors.New("failure") } blockResult, newState, err := s.DeliverBlock(context.Background(), &appmanager.BlockRequest[mock.Tx]{ Height: uint64(1), Time: time.Date(2024, 2, 3, 18, 23, 0, 0, time.UTC), diff --git a/store/v2/commitment/store.go b/store/v2/commitment/store.go index 0dda7f282903..9d7be8a0062e 100644 --- a/store/v2/commitment/store.go +++ b/store/v2/commitment/store.go @@ -244,7 +244,7 @@ func (c *CommitStore) PausePruning(pause bool) { // Snapshot implements snapshotstypes.CommitSnapshotter. func (c *CommitStore) Snapshot(version uint64, protoWriter protoio.Writer) error { if version == 0 { - return fmt.Errorf("the snapshot version must be greater than 0") + return errors.New("the snapshot version must be greater than 0") } latestVersion, err := c.GetLatestVersion() @@ -348,7 +348,7 @@ loop: case *snapshotstypes.SnapshotItem_IAVL: if importer == nil { - return snapshotstypes.SnapshotItem{}, fmt.Errorf("received IAVL node item before store item") + return snapshotstypes.SnapshotItem{}, errors.New("received IAVL node item before store item") } node := item.IAVL if node.Height > int32(math.MaxInt8) { diff --git a/store/v2/migration/manager.go b/store/v2/migration/manager.go index bd636dc3c600..e71d97877e62 100644 --- a/store/v2/migration/manager.go +++ b/store/v2/migration/manager.go @@ -215,7 +215,7 @@ func (m *Manager) GetMigratedVersion() uint64 { func (m *Manager) Sync() error { version := m.GetMigratedVersion() if version == 0 { - return fmt.Errorf("migration is not done yet") + return errors.New("migration is not done yet") } version += 1 diff --git a/tests/integration/example/example_test.go b/tests/integration/example/example_test.go index 56f49dab8ed4..b8bac7848849 100644 --- a/tests/integration/example/example_test.go +++ b/tests/integration/example/example_test.go @@ -2,6 +2,7 @@ package integration_test import ( "context" + "errors" "fmt" "io" "testing" @@ -112,7 +113,7 @@ func Example() { // in this example the result is an empty response, a nil check is enough // in other cases, it is recommended to check the result value. if result == nil { - panic(fmt.Errorf("unexpected nil result")) + panic(errors.New("unexpected nil result")) } // we now check the result @@ -220,7 +221,7 @@ func Example_oneModule() { // in this example the result is an empty response, a nil check is enough // in other cases, it is recommended to check the result value. if result == nil { - panic(fmt.Errorf("unexpected nil result")) + panic(errors.New("unexpected nil result")) } // we now check the result diff --git a/testutil/network/network.go b/testutil/network/network.go index fb2bbd54ae69..7929846bac96 100644 --- a/testutil/network/network.go +++ b/testutil/network/network.go @@ -350,7 +350,7 @@ func New(l Logger, baseDir string, cfg Config) (NetworkI, error) { apiListenAddr = cfg.APIAddress } else { if len(portPool) == 0 { - return nil, fmt.Errorf("failed to get port for API server") + return nil, errors.New("failed to get port for API server") } port := <-portPool apiListenAddr = fmt.Sprintf("tcp://127.0.0.1:%s", port) @@ -367,7 +367,7 @@ func New(l Logger, baseDir string, cfg Config) (NetworkI, error) { cmtCfg.RPC.ListenAddress = cfg.RPCAddress } else { if len(portPool) == 0 { - return nil, fmt.Errorf("failed to get port for RPC server") + return nil, errors.New("failed to get port for RPC server") } port := <-portPool cmtCfg.RPC.ListenAddress = fmt.Sprintf("tcp://127.0.0.1:%s", port) @@ -377,7 +377,7 @@ func New(l Logger, baseDir string, cfg Config) (NetworkI, error) { appCfg.GRPC.Address = cfg.GRPCAddress } else { if len(portPool) == 0 { - return nil, fmt.Errorf("failed to get port for GRPC server") + return nil, errors.New("failed to get port for GRPC server") } port := <-portPool appCfg.GRPC.Address = fmt.Sprintf("127.0.0.1:%s", port) @@ -410,14 +410,14 @@ func New(l Logger, baseDir string, cfg Config) (NetworkI, error) { monikers[i] = nodeDirName if len(portPool) == 0 { - return nil, fmt.Errorf("failed to get port for Proxy server") + return nil, errors.New("failed to get port for Proxy server") } port := <-portPool proxyAddr := fmt.Sprintf("tcp://127.0.0.1:%s", port) cmtCfg.ProxyApp = proxyAddr if len(portPool) == 0 { - return nil, fmt.Errorf("failed to get port for Proxy server") + return nil, errors.New("failed to get port for Proxy server") } port = <-portPool p2pAddr := fmt.Sprintf("tcp://127.0.0.1:%s", port) diff --git a/testutil/sims/address_helpers.go b/testutil/sims/address_helpers.go index 0f6d85e275cc..d0b8bb8ce7fc 100644 --- a/testutil/sims/address_helpers.go +++ b/testutil/sims/address_helpers.go @@ -3,7 +3,7 @@ package sims import ( "bytes" "encoding/hex" - "fmt" + "errors" "strconv" errorsmod "cosmossdk.io/errors" @@ -108,7 +108,7 @@ func TestAddr(addr, bech string) (sdk.AccAddress, error) { } bechexpected := res.String() if bech != bechexpected { - return nil, fmt.Errorf("bech encoding doesn't match reference") + return nil, errors.New("bech encoding doesn't match reference") } bechres, err := sdk.AccAddressFromBech32(bech) diff --git a/testutil/sims/app_helpers.go b/testutil/sims/app_helpers.go index 720713ca56ac..1a1762d78437 100644 --- a/testutil/sims/app_helpers.go +++ b/testutil/sims/app_helpers.go @@ -2,6 +2,7 @@ package sims import ( "encoding/json" + "errors" "fmt" "time" @@ -164,7 +165,7 @@ func SetupWithConfiguration(appConfig depinject.Config, startupConfig StartupCon // create validator set valSet, err := startupConfig.ValidatorSet() if err != nil { - return nil, fmt.Errorf("failed to create validator set") + return nil, errors.New("failed to create validator set") } var ( diff --git a/testutil/sims/state_helpers.go b/testutil/sims/state_helpers.go index 8a3ce8a488a3..631ec379b81f 100644 --- a/testutil/sims/state_helpers.go +++ b/testutil/sims/state_helpers.go @@ -3,7 +3,7 @@ package sims import ( "bufio" "encoding/json" - "fmt" + "errors" "io" "math/rand" "os" @@ -289,7 +289,7 @@ func AppStateFromGenesisFileFn(r io.Reader, cdc codec.JSONCodec, genesisFile str a, ok := acc.GetCachedValue().(sdk.AccountI) if !ok { - return *genesis, nil, fmt.Errorf("expected account") + return *genesis, nil, errors.New("expected account") } // create simulator accounts diff --git a/testutil/testdata/grpc_query.go b/testutil/testdata/grpc_query.go index d4ca6c73d888..a8b4d75b0621 100644 --- a/testutil/testdata/grpc_query.go +++ b/testutil/testdata/grpc_query.go @@ -2,6 +2,7 @@ package testdata import ( "context" + "errors" "fmt" "testing" @@ -27,7 +28,7 @@ var _ QueryServer = QueryImpl{} func (e QueryImpl) TestAny(_ context.Context, request *TestAnyRequest) (*TestAnyResponse, error) { animal, ok := request.AnyAnimal.GetCachedValue().(test.Animal) if !ok { - return nil, fmt.Errorf("expected Animal") + return nil, errors.New("expected Animal") } any, err := types.NewAnyWithValue(animal.(proto.Message)) diff --git a/tools/cosmovisor/args.go b/tools/cosmovisor/args.go index e89112749b30..40e2553631b3 100644 --- a/tools/cosmovisor/args.go +++ b/tools/cosmovisor/args.go @@ -310,7 +310,7 @@ func parseEnvDuration(input string) (time.Duration, error) { } if duration <= 0 { - return 0, fmt.Errorf("must be greater than 0") + return 0, errors.New("must be greater than 0") } return duration, nil diff --git a/tools/hubl/internal/version.go b/tools/hubl/internal/version.go index 87a0d57c1d1b..d4dbff188a37 100644 --- a/tools/hubl/internal/version.go +++ b/tools/hubl/internal/version.go @@ -1,7 +1,7 @@ package internal import ( - "fmt" + "errors" "runtime/debug" "strings" @@ -19,7 +19,7 @@ func VersionCmd() *cobra.Command { RunE: func(cmd *cobra.Command, args []string) error { version, ok := debug.ReadBuildInfo() if !ok { - return fmt.Errorf("failed to get hubl version") + return errors.New("failed to get hubl version") } cmd.Printf("hubl version: %s\n", strings.TrimSpace(version.Main.Version)) diff --git a/types/collections.go b/types/collections.go index cf7ad0cb2257..79d9b4fca55a 100644 --- a/types/collections.go +++ b/types/collections.go @@ -2,6 +2,7 @@ package types import ( "encoding/binary" + "errors" "fmt" "time" @@ -255,7 +256,7 @@ var timeSize = len(FormatTimeBytes(time.Time{})) func (timeKeyCodec) Decode(buffer []byte) (int, time.Time, error) { if len(buffer) != timeSize { - return 0, time.Time{}, fmt.Errorf("invalid time buffer size") + return 0, time.Time{}, errors.New("invalid time buffer size") } t, err := ParseTimeBytes(buffer) if err != nil { diff --git a/types/mempool/mempool_test.go b/types/mempool/mempool_test.go index 8cfb1d0252f1..01c1fdd90028 100644 --- a/types/mempool/mempool_test.go +++ b/types/mempool/mempool_test.go @@ -1,6 +1,7 @@ package mempool_test import ( + "errors" "fmt" "math/rand" "testing" @@ -217,7 +218,7 @@ func (s *MempoolTestSuite) TestDefaultMempool() { // a tx which does not implement SigVerifiableTx should not be inserted tx := &sigErrTx{getSigs: func() ([]txsigning.SignatureV2, error) { - return nil, fmt.Errorf("error") + return nil, errors.New("error") }} require.Error(t, s.mempool.Insert(ctx, tx)) require.Error(t, s.mempool.Remove(tx)) diff --git a/types/mempool/priority_nonce.go b/types/mempool/priority_nonce.go index f0df79e70882..a927693410ef 100644 --- a/types/mempool/priority_nonce.go +++ b/types/mempool/priority_nonce.go @@ -2,6 +2,7 @@ package mempool import ( "context" + "errors" "fmt" "math" "sync" @@ -215,7 +216,7 @@ func (mp *PriorityNonceMempool[C]) Insert(ctx context.Context, tx sdk.Tx) error return err } if len(sigs) == 0 { - return fmt.Errorf("tx must have at least one signer") + return errors.New("tx must have at least one signer") } sig := sigs[0] @@ -436,7 +437,7 @@ func (mp *PriorityNonceMempool[C]) Remove(tx sdk.Tx) error { return err } if len(sigs) == 0 { - return fmt.Errorf("attempted to remove a tx with no signatures") + return errors.New("attempted to remove a tx with no signatures") } sig := sigs[0] @@ -466,7 +467,7 @@ func (mp *PriorityNonceMempool[C]) Remove(tx sdk.Tx) error { func IsEmpty[C comparable](mempool Mempool) error { mp := mempool.(*PriorityNonceMempool[C]) if mp.priorityIndex.Len() != 0 { - return fmt.Errorf("priorityIndex not empty") + return errors.New("priorityIndex not empty") } countKeys := make([]C, 0, len(mp.priorityCounts)) diff --git a/types/mempool/sender_nonce.go b/types/mempool/sender_nonce.go index 9e2b25e4e47d..fc4902f64792 100644 --- a/types/mempool/sender_nonce.go +++ b/types/mempool/sender_nonce.go @@ -4,7 +4,7 @@ import ( "context" crand "crypto/rand" // #nosec // crypto/rand is used for seed generation "encoding/binary" - "fmt" + "errors" "math/rand" // #nosec // math/rand is used for random selection and seeded from crypto/rand "sync" @@ -133,7 +133,7 @@ func (snm *SenderNonceMempool) Insert(_ context.Context, tx sdk.Tx) error { return err } if len(sigs) == 0 { - return fmt.Errorf("tx must have at least one signer") + return errors.New("tx must have at least one signer") } sig := sigs[0] @@ -206,7 +206,7 @@ func (snm *SenderNonceMempool) Remove(tx sdk.Tx) error { return err } if len(sigs) == 0 { - return fmt.Errorf("tx must have at least one signer") + return errors.New("tx must have at least one signer") } sig := sigs[0] diff --git a/types/mempool/signer_extraction_adapater_test.go b/types/mempool/signer_extraction_adapater_test.go index 77531956a08d..6bc88a87d59b 100644 --- a/types/mempool/signer_extraction_adapater_test.go +++ b/types/mempool/signer_extraction_adapater_test.go @@ -1,6 +1,7 @@ package mempool_test import ( + "errors" "fmt" "math/rand" "testing" @@ -52,7 +53,7 @@ func TestDefaultSignerExtractor(t *testing.T) { ext := mempool.NewDefaultSignerExtractionAdapter() goodTx := testTx{id: 0, priority: 0, nonce: 0, address: sa} badTx := &sigErrTx{getSigs: func() ([]txsigning.SignatureV2, error) { - return nil, fmt.Errorf("error") + return nil, errors.New("error") }} nonSigVerify := nonVerifiableTx{} @@ -63,7 +64,7 @@ func TestDefaultSignerExtractor(t *testing.T) { err error }{ {name: "valid tx extracts sigs", tx: goodTx, sea: ext, err: nil}, - {name: "invalid tx fails on sig", tx: badTx, sea: ext, err: fmt.Errorf("err")}, + {name: "invalid tx fails on sig", tx: badTx, sea: ext, err: errors.New("err")}, {name: "non-verifiable tx fails on conversion", tx: nonSigVerify, sea: ext, err: fmt.Errorf("tx of type %T does not implement SigVerifiableTx", nonSigVerify)}, } for _, test := range tests { diff --git a/types/query/collections_pagination.go b/types/query/collections_pagination.go index fb17fd8c56e4..2877df26396c 100644 --- a/types/query/collections_pagination.go +++ b/types/query/collections_pagination.go @@ -3,7 +3,6 @@ package query import ( "context" "errors" - "fmt" "cosmossdk.io/collections" collcodec "cosmossdk.io/collections/codec" @@ -87,7 +86,7 @@ func CollectionFilteredPaginate[K, V any, C Collection[K, V], T any]( reverse := pageReq.Reverse if offset > 0 && key != nil { - return nil, nil, fmt.Errorf("invalid request, either offset or key is expected, got both") + return nil, nil, errors.New("invalid request, either offset or key is expected, got both") } opt := new(CollectionsPaginateOptions[K]) diff --git a/types/query/filtered_pagination.go b/types/query/filtered_pagination.go index 7d57aa8f534f..1eafe6321b33 100644 --- a/types/query/filtered_pagination.go +++ b/types/query/filtered_pagination.go @@ -1,7 +1,7 @@ package query import ( - "fmt" + "errors" "github.com/cosmos/gogoproto/proto" @@ -26,7 +26,7 @@ func FilteredPaginate( pageRequest = initPageRequestDefaults(pageRequest) if pageRequest.Offset > 0 && pageRequest.Key != nil { - return nil, fmt.Errorf("invalid request, either offset or key is expected, got both") + return nil, errors.New("invalid request, either offset or key is expected, got both") } var ( @@ -151,7 +151,7 @@ func GenericFilteredPaginate[T, F proto.Message]( results := []F{} if pageRequest.Offset > 0 && pageRequest.Key != nil { - return results, nil, fmt.Errorf("invalid request, either offset or key is expected, got both") + return results, nil, errors.New("invalid request, either offset or key is expected, got both") } var ( diff --git a/types/query/pagination.go b/types/query/pagination.go index 110dc57fa2e7..c26ca38ff73b 100644 --- a/types/query/pagination.go +++ b/types/query/pagination.go @@ -1,7 +1,7 @@ package query import ( - "fmt" + "errors" "math" db "github.com/cosmos/cosmos-db" @@ -62,7 +62,7 @@ func Paginate( pageRequest = initPageRequestDefaults(pageRequest) if pageRequest.Offset > 0 && pageRequest.Key != nil { - return nil, fmt.Errorf("invalid request, either offset or key is expected, got both") + return nil, errors.New("invalid request, either offset or key is expected, got both") } iterator := getIterator(prefixStore, pageRequest.Key, pageRequest.Reverse) diff --git a/types/simulation/account.go b/types/simulation/account.go index 0c3f786b5f36..d046ea23e284 100644 --- a/types/simulation/account.go +++ b/types/simulation/account.go @@ -1,7 +1,7 @@ package simulation import ( - "fmt" + "errors" "math/rand" "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" @@ -90,7 +90,7 @@ func RandomFees(r *rand.Rand, spendableCoins sdk.Coins) (sdk.Coins, error) { } if randCoin.Amount.IsZero() { - return nil, fmt.Errorf("no coins found for random fees") + return nil, errors.New("no coins found for random fees") } amt, err := RandPositiveInt(r, randCoin.Amount) diff --git a/x/protocolpool/keeper/genesis.go b/x/protocolpool/keeper/genesis.go index fa32a08f9a50..0a371f453103 100644 --- a/x/protocolpool/keeper/genesis.go +++ b/x/protocolpool/keeper/genesis.go @@ -2,6 +2,7 @@ package keeper import ( "context" + "errors" "fmt" "time" @@ -65,7 +66,7 @@ func (k Keeper) InitGenesis(ctx context.Context, data *types.GenesisState) error // sanity check to avoid trying to distribute more than what is available if data.LastBalance.LT(totalToBeDistributed) { - return fmt.Errorf("total to be distributed is greater than the last balance") + return errors.New("total to be distributed is greater than the last balance") } return nil From 897f4f8484c108c24cdf4ea08c77befb1da97e9a Mon Sep 17 00:00:00 2001 From: Alexander Peters Date: Thu, 25 Jul 2024 14:55:49 +0200 Subject: [PATCH 46/50] ci: Use large box for 052 branch sims on CI (#21067) --- .github/workflows/sims-052.yml | 67 +++++++++++++++------------------- 1 file changed, 29 insertions(+), 38 deletions(-) diff --git a/.github/workflows/sims-052.yml b/.github/workflows/sims-052.yml index e79a04786098..b64d6332b76f 100644 --- a/.github/workflows/sims-052.yml +++ b/.github/workflows/sims-052.yml @@ -13,7 +13,9 @@ concurrency: jobs: build: - runs-on: ubuntu-latest + permissions: + contents: read # for actions/checkout to fetch code + runs-on: large-sdk-runner if: "!contains(github.event.head_commit.message, 'skip-sims')" steps: - uses: actions/checkout@v4 @@ -25,26 +27,9 @@ jobs: check-latest: true - run: make build - install-runsim: - permissions: - contents: none - runs-on: ubuntu-latest - needs: build - steps: - - uses: actions/setup-go@v5 - with: - go-version: "1.22" - check-latest: true - - name: Install runsim - run: go install github.com/cosmos/tools/cmd/runsim@v1.0.0 - - uses: actions/cache@v4 - with: - path: ~/go/bin - key: ${{ runner.os }}-go-runsim-binary - test-sim-import-export: - runs-on: ubuntu-latest - needs: [build, install-runsim] + runs-on: large-sdk-runner + needs: [build] timeout-minutes: 60 steps: - uses: actions/checkout@v4 @@ -54,17 +39,14 @@ jobs: with: go-version: "1.22" check-latest: true - - uses: actions/cache@v4 - with: - path: ~/go/bin - key: ${{ runner.os }}-go-runsim-binary - name: test-sim-import-export run: | make test-sim-import-export test-sim-after-import: - runs-on: ubuntu-latest - needs: [build, install-runsim] + runs-on: large-sdk-runner + needs: [build] + timeout-minutes: 60 steps: - uses: actions/checkout@v4 with: @@ -73,17 +55,14 @@ jobs: with: go-version: "1.22" check-latest: true - - uses: actions/cache@v4 - with: - path: ~/go/bin - key: ${{ runner.os }}-go-runsim-binary - name: test-sim-after-import run: | make test-sim-after-import - test-sim-multi-seed-short: - runs-on: ubuntu-latest - needs: [build, install-runsim] + test-sim-deterministic: + runs-on: large-sdk-runner + needs: [build] + timeout-minutes: 60 steps: - uses: actions/checkout@v4 with: @@ -92,10 +71,22 @@ jobs: with: go-version: "1.22" check-latest: true - - uses: actions/cache@v4 + - name: test-sim-nondeterminism-streaming + run: | + make test-sim-nondeterminism-streaming + + test-sim-multi-seed-short: + runs-on: large-sdk-runner + needs: [build] + timeout-minutes: 60 + steps: + - uses: actions/checkout@v4 + with: + ref: "release/v0.52.x" + - uses: actions/setup-go@v5 with: - path: ~/go/bin - key: ${{ runner.os }}-go-runsim-binary + go-version: "1.22" + check-latest: true - name: test-sim-multi-seed-short run: | make test-sim-multi-seed-short @@ -103,7 +94,7 @@ jobs: sims-notify-success: needs: [test-sim-multi-seed-short, test-sim-after-import, test-sim-import-export] - runs-on: ubuntu-latest + runs-on: large-sdk-runner if: ${{ success() }} steps: - uses: actions/checkout@v4 @@ -130,7 +121,7 @@ jobs: contents: none needs: [test-sim-multi-seed-short, test-sim-after-import, test-sim-import-export] - runs-on: ubuntu-latest + runs-on: large-sdk-runner if: ${{ failure() }} steps: - name: Notify Slack on failure From 683371f7791792c7b4e74d18321e8d08039780d4 Mon Sep 17 00:00:00 2001 From: Aaron Craelius Date: Thu, 25 Jul 2024 15:53:26 +0200 Subject: [PATCH 47/50] feat(schema/appdata): async listener mux'ing (#20879) Co-authored-by: cool-developer <51834436+cool-develope@users.noreply.github.com> --- schema/appdata/async.go | 162 +++++++++++++++++++++++++++++++++++ schema/appdata/async_test.go | 148 ++++++++++++++++++++++++++++++++ schema/appdata/mux.go | 128 +++++++++++++++++++++++++++ schema/appdata/mux_test.go | 131 ++++++++++++++++++++++++++++ 4 files changed, 569 insertions(+) create mode 100644 schema/appdata/async.go create mode 100644 schema/appdata/async_test.go create mode 100644 schema/appdata/mux.go create mode 100644 schema/appdata/mux_test.go diff --git a/schema/appdata/async.go b/schema/appdata/async.go new file mode 100644 index 000000000000..0d4126ed2a03 --- /dev/null +++ b/schema/appdata/async.go @@ -0,0 +1,162 @@ +package appdata + +import ( + "context" + "sync" +) + +// AsyncListenerOptions are options for async listeners and listener mux's. +type AsyncListenerOptions struct { + // Context is the context whose Done() channel listeners use will use to listen for completion to close their + // goroutine. If it is nil, then context.Background() will be used and goroutines may be leaked. + Context context.Context + + // BufferSize is the buffer size of the channels to use. It defaults to 0. + BufferSize int + + // DoneWaitGroup is an optional wait-group that listener goroutines will notify via Add(1) when they are started + // and Done() after they are cancelled and completed. + DoneWaitGroup *sync.WaitGroup +} + +// AsyncListenerMux returns a listener that forwards received events to all the provided listeners asynchronously +// with each listener processing in a separate go routine. All callbacks in the returned listener will return nil +// except for Commit which will return an error or nil once all listeners have processed the commit. The context +// is used to signal that the listeners should stop listening and return. bufferSize is the size of the buffer for the +// channels used to send events to the listeners. +func AsyncListenerMux(opts AsyncListenerOptions, listeners ...Listener) Listener { + asyncListeners := make([]Listener, len(listeners)) + commitChans := make([]chan error, len(listeners)) + for i, l := range listeners { + commitChan := make(chan error) + commitChans[i] = commitChan + asyncListeners[i] = AsyncListener(opts, commitChan, l) + } + mux := ListenerMux(asyncListeners...) + muxCommit := mux.Commit + mux.Commit = func(data CommitData) error { + if muxCommit != nil { + err := muxCommit(data) + if err != nil { + return err + } + } + + for _, commitChan := range commitChans { + err := <-commitChan + if err != nil { + return err + } + } + return nil + } + + return mux +} + +// AsyncListener returns a listener that forwards received events to the provided listener listening in asynchronously +// in a separate go routine. The listener that is returned will return nil for all methods including Commit and +// an error or nil will only be returned in commitChan once the sender has sent commit and the receiving listener has +// processed it. Thus commitChan can be used as a synchronization and error checking mechanism. The go routine +// that is being used for listening will exit when context.Done() returns and no more events will be received by the listener. +// bufferSize is the size of the buffer for the channel that is used to send events to the listener. +// Instead of using AsyncListener directly, it is recommended to use AsyncListenerMux which does coordination directly +// via its Commit callback. +func AsyncListener(opts AsyncListenerOptions, commitChan chan<- error, listener Listener) Listener { + packetChan := make(chan Packet, opts.BufferSize) + res := Listener{} + ctx := opts.Context + if ctx == nil { + ctx = context.Background() + } + done := ctx.Done() + + go func() { + if opts.DoneWaitGroup != nil { + opts.DoneWaitGroup.Add(1) + } + + var err error + for { + select { + case packet := <-packetChan: + if err != nil { + // if we have an error, don't process any more packets + // and return the error and finish when it's time to commit + if _, ok := packet.(CommitData); ok { + commitChan <- err + return + } + } else { + // process the packet + err = listener.SendPacket(packet) + // if it's a commit + if _, ok := packet.(CommitData); ok { + commitChan <- err + if err != nil { + return + } + } + } + + case <-done: + close(packetChan) + if opts.DoneWaitGroup != nil { + opts.DoneWaitGroup.Done() + } + return + } + } + }() + + if listener.InitializeModuleData != nil { + res.InitializeModuleData = func(data ModuleInitializationData) error { + packetChan <- data + return nil + } + } + + if listener.StartBlock != nil { + res.StartBlock = func(data StartBlockData) error { + packetChan <- data + return nil + } + } + + if listener.OnTx != nil { + res.OnTx = func(data TxData) error { + packetChan <- data + return nil + } + } + + if listener.OnEvent != nil { + res.OnEvent = func(data EventData) error { + packetChan <- data + return nil + } + } + + if listener.OnKVPair != nil { + res.OnKVPair = func(data KVPairData) error { + packetChan <- data + return nil + } + } + + if listener.OnObjectUpdate != nil { + res.OnObjectUpdate = func(data ObjectUpdateData) error { + packetChan <- data + return nil + } + } + + if listener.Commit != nil { + res.Commit = func(data CommitData) error { + packetChan <- data + return nil + } + } + + return res +} diff --git a/schema/appdata/async_test.go b/schema/appdata/async_test.go new file mode 100644 index 000000000000..c1df2d4ca6c0 --- /dev/null +++ b/schema/appdata/async_test.go @@ -0,0 +1,148 @@ +package appdata + +import ( + "context" + "fmt" + "sync" + "testing" +) + +func TestAsyncListenerMux(t *testing.T) { + t.Run("empty", func(t *testing.T) { + listener := AsyncListenerMux(AsyncListenerOptions{}, Listener{}, Listener{}) + + if listener.InitializeModuleData != nil { + t.Error("expected nil") + } + if listener.StartBlock != nil { + t.Error("expected nil") + } + if listener.OnTx != nil { + t.Error("expected nil") + } + if listener.OnEvent != nil { + t.Error("expected nil") + } + if listener.OnKVPair != nil { + t.Error("expected nil") + } + if listener.OnObjectUpdate != nil { + t.Error("expected nil") + } + + // commit is not expected to be nil + }) + + t.Run("call cancel", func(t *testing.T) { + ctx, cancel := context.WithCancel(context.Background()) + wg := &sync.WaitGroup{} + var calls1, calls2 []string + listener1 := callCollector(1, func(name string, _ int, _ Packet) { + calls1 = append(calls1, name) + }) + listener2 := callCollector(2, func(name string, _ int, _ Packet) { + calls2 = append(calls2, name) + }) + res := AsyncListenerMux(AsyncListenerOptions{ + BufferSize: 16, Context: ctx, DoneWaitGroup: wg, + }, listener1, listener2) + + callAllCallbacksOnces(t, res) + + expectedCalls := []string{ + "InitializeModuleData", + "StartBlock", + "OnTx", + "OnEvent", + "OnKVPair", + "OnObjectUpdate", + "Commit", + } + + checkExpectedCallOrder(t, calls1, expectedCalls) + checkExpectedCallOrder(t, calls2, expectedCalls) + + // cancel and expect the test to finish - if all goroutines aren't canceled the test will hang + cancel() + wg.Wait() + }) + + t.Run("error on commit", func(t *testing.T) { + var calls1, calls2 []string + listener1 := callCollector(1, func(name string, _ int, _ Packet) { + calls1 = append(calls1, name) + }) + listener1.Commit = func(data CommitData) error { + return fmt.Errorf("error") + } + listener2 := callCollector(2, func(name string, _ int, _ Packet) { + calls2 = append(calls2, name) + }) + res := AsyncListenerMux(AsyncListenerOptions{}, listener1, listener2) + + err := res.Commit(CommitData{}) + if err == nil || err.Error() != "error" { + t.Fatalf("expected error, got %v", err) + } + }) +} + +func TestAsyncListener(t *testing.T) { + t.Run("call cancel", func(t *testing.T) { + commitChan := make(chan error) + ctx, cancel := context.WithCancel(context.Background()) + wg := &sync.WaitGroup{} + var calls []string + listener := callCollector(1, func(name string, _ int, _ Packet) { + calls = append(calls, name) + }) + res := AsyncListener(AsyncListenerOptions{BufferSize: 16, Context: ctx, DoneWaitGroup: wg}, + commitChan, listener) + + callAllCallbacksOnces(t, res) + + err := <-commitChan + if err != nil { + t.Fatalf("expected nil, got %v", err) + } + + checkExpectedCallOrder(t, calls, []string{ + "InitializeModuleData", + "StartBlock", + "OnTx", + "OnEvent", + "OnKVPair", + "OnObjectUpdate", + "Commit", + }) + + calls = nil + + // expect wait group to return after cancel is called + cancel() + wg.Wait() + }) + + t.Run("error", func(t *testing.T) { + commitChan := make(chan error) + var calls []string + listener := callCollector(1, func(name string, _ int, _ Packet) { + calls = append(calls, name) + }) + + listener.OnKVPair = func(updates KVPairData) error { + return fmt.Errorf("error") + } + + res := AsyncListener(AsyncListenerOptions{BufferSize: 16}, commitChan, listener) + + callAllCallbacksOnces(t, res) + + err := <-commitChan + if err == nil || err.Error() != "error" { + t.Fatalf("expected error, got %v", err) + } + + checkExpectedCallOrder(t, calls, []string{"InitializeModuleData", "StartBlock", "OnTx", "OnEvent"}) + }) +} diff --git a/schema/appdata/mux.go b/schema/appdata/mux.go new file mode 100644 index 000000000000..8e6b886577d2 --- /dev/null +++ b/schema/appdata/mux.go @@ -0,0 +1,128 @@ +package appdata + +// ListenerMux returns a listener that forwards received events to all the provided listeners in order. +// A callback is only registered if a non-nil callback is present in at least one of the listeners. +func ListenerMux(listeners ...Listener) Listener { + mux := Listener{} + + initModDataCbs := make([]func(ModuleInitializationData) error, 0, len(listeners)) + for _, l := range listeners { + if l.InitializeModuleData != nil { + initModDataCbs = append(initModDataCbs, l.InitializeModuleData) + } + } + if len(initModDataCbs) > 0 { + mux.InitializeModuleData = func(data ModuleInitializationData) error { + for _, cb := range initModDataCbs { + if err := cb(data); err != nil { + return err + } + } + return nil + } + } + + startBlockCbs := make([]func(StartBlockData) error, 0, len(listeners)) + for _, l := range listeners { + if l.StartBlock != nil { + startBlockCbs = append(startBlockCbs, l.StartBlock) + } + } + if len(startBlockCbs) > 0 { + mux.StartBlock = func(data StartBlockData) error { + for _, cb := range startBlockCbs { + if err := cb(data); err != nil { + return err + } + } + return nil + } + } + + onTxCbs := make([]func(TxData) error, 0, len(listeners)) + for _, l := range listeners { + if l.OnTx != nil { + onTxCbs = append(onTxCbs, l.OnTx) + } + } + if len(onTxCbs) > 0 { + mux.OnTx = func(data TxData) error { + for _, cb := range onTxCbs { + if err := cb(data); err != nil { + return err + } + } + return nil + } + } + + onEventCbs := make([]func(EventData) error, 0, len(listeners)) + for _, l := range listeners { + if l.OnEvent != nil { + onEventCbs = append(onEventCbs, l.OnEvent) + } + } + if len(onEventCbs) > 0 { + mux.OnEvent = func(data EventData) error { + for _, cb := range onEventCbs { + if err := cb(data); err != nil { + return err + } + } + return nil + } + } + + onKvPairCbs := make([]func(KVPairData) error, 0, len(listeners)) + for _, l := range listeners { + if l.OnKVPair != nil { + onKvPairCbs = append(onKvPairCbs, l.OnKVPair) + } + } + if len(onKvPairCbs) > 0 { + mux.OnKVPair = func(data KVPairData) error { + for _, cb := range onKvPairCbs { + if err := cb(data); err != nil { + return err + } + } + return nil + } + } + + onObjectUpdateCbs := make([]func(ObjectUpdateData) error, 0, len(listeners)) + for _, l := range listeners { + if l.OnObjectUpdate != nil { + onObjectUpdateCbs = append(onObjectUpdateCbs, l.OnObjectUpdate) + } + } + if len(onObjectUpdateCbs) > 0 { + mux.OnObjectUpdate = func(data ObjectUpdateData) error { + for _, cb := range onObjectUpdateCbs { + if err := cb(data); err != nil { + return err + } + } + return nil + } + } + + commitCbs := make([]func(CommitData) error, 0, len(listeners)) + for _, l := range listeners { + if l.Commit != nil { + commitCbs = append(commitCbs, l.Commit) + } + } + if len(commitCbs) > 0 { + mux.Commit = func(data CommitData) error { + for _, cb := range commitCbs { + if err := cb(data); err != nil { + return err + } + } + return nil + } + } + + return mux +} diff --git a/schema/appdata/mux_test.go b/schema/appdata/mux_test.go new file mode 100644 index 000000000000..b5e3a95dd569 --- /dev/null +++ b/schema/appdata/mux_test.go @@ -0,0 +1,131 @@ +package appdata + +import ( + "fmt" + "testing" +) + +func TestListenerMux(t *testing.T) { + t.Run("empty", func(t *testing.T) { + listener := ListenerMux(Listener{}, Listener{}) + + if listener.InitializeModuleData != nil { + t.Error("expected nil") + } + if listener.StartBlock != nil { + t.Error("expected nil") + } + if listener.OnTx != nil { + t.Error("expected nil") + } + if listener.OnEvent != nil { + t.Error("expected nil") + } + if listener.OnKVPair != nil { + t.Error("expected nil") + } + if listener.OnObjectUpdate != nil { + t.Error("expected nil") + } + if listener.Commit != nil { + t.Error("expected nil") + } + }) + + t.Run("all called once", func(t *testing.T) { + var calls []string + onCall := func(name string, i int, _ Packet) { + calls = append(calls, fmt.Sprintf("%s %d", name, i)) + } + + res := ListenerMux(callCollector(1, onCall), callCollector(2, onCall)) + + callAllCallbacksOnces(t, res) + + checkExpectedCallOrder(t, calls, []string{ + "InitializeModuleData 1", + "InitializeModuleData 2", + "StartBlock 1", + "StartBlock 2", + "OnTx 1", + "OnTx 2", + "OnEvent 1", + "OnEvent 2", + "OnKVPair 1", + "OnKVPair 2", + "OnObjectUpdate 1", + "OnObjectUpdate 2", + "Commit 1", + "Commit 2", + }) + }) +} + +func callAllCallbacksOnces(t *testing.T, listener Listener) { + if err := listener.InitializeModuleData(ModuleInitializationData{}); err != nil { + t.Error(err) + } + if err := listener.StartBlock(StartBlockData{}); err != nil { + t.Error(err) + } + if err := listener.OnTx(TxData{}); err != nil { + t.Error(err) + } + if err := listener.OnEvent(EventData{}); err != nil { + t.Error(err) + } + if err := listener.OnKVPair(KVPairData{}); err != nil { + t.Error(err) + } + if err := listener.OnObjectUpdate(ObjectUpdateData{}); err != nil { + t.Error(err) + } + if err := listener.Commit(CommitData{}); err != nil { + t.Error(err) + } +} + +func callCollector(i int, onCall func(string, int, Packet)) Listener { + return Listener{ + InitializeModuleData: func(ModuleInitializationData) error { + onCall("InitializeModuleData", i, nil) + return nil + }, + StartBlock: func(StartBlockData) error { + onCall("StartBlock", i, nil) + return nil + }, + OnTx: func(TxData) error { + onCall("OnTx", i, nil) + return nil + }, + OnEvent: func(EventData) error { + onCall("OnEvent", i, nil) + return nil + }, + OnKVPair: func(KVPairData) error { + onCall("OnKVPair", i, nil) + return nil + }, + OnObjectUpdate: func(ObjectUpdateData) error { + onCall("OnObjectUpdate", i, nil) + return nil + }, + Commit: func(CommitData) error { + onCall("Commit", i, nil) + return nil + }, + } +} + +func checkExpectedCallOrder(t *testing.T, actual, expected []string) { + if len(actual) != len(expected) { + t.Fatalf("expected %d calls, got %d", len(expected), len(actual)) + } + + for i := range actual { + if actual[i] != expected[i] { + t.Errorf("expected %q, got %q", expected[i], actual[i]) + } + } +} From a0207294c5a93f4dbef5cc067ff6c55ee9899597 Mon Sep 17 00:00:00 2001 From: Aaron Craelius Date: Thu, 25 Jul 2024 18:36:17 +0200 Subject: [PATCH 48/50] chore(indexer/postgres): update to changes on main (#21077) --- indexer/postgres/column.go | 4 +-- indexer/postgres/enum.go | 30 ++-------------- indexer/postgres/go.mod | 2 ++ indexer/postgres/go.sum | 2 -- .../internal/testdata/example_schema.go | 34 +++++++++++-------- indexer/postgres/module.go | 32 ++++++++--------- indexer/postgres/tests/go.mod | 2 ++ indexer/postgres/tests/go.sum | 2 -- 8 files changed, 43 insertions(+), 65 deletions(-) diff --git a/indexer/postgres/column.go b/indexer/postgres/column.go index f9692af13711..188e9d8da651 100644 --- a/indexer/postgres/column.go +++ b/indexer/postgres/column.go @@ -25,7 +25,7 @@ func (tm *ObjectIndexer) createColumnDefinition(writer io.Writer, field schema.F } else { switch field.Kind { case schema.EnumKind: - _, err = fmt.Fprintf(writer, "%q", enumTypeName(tm.moduleName, field.EnumDefinition)) + _, err = fmt.Fprintf(writer, "%q", enumTypeName(tm.moduleName, field.EnumType)) if err != nil { return err } @@ -100,7 +100,7 @@ func simpleColumnType(kind schema.Kind) string { return "JSONB" case schema.DurationKind: return "BIGINT" - case schema.Bech32AddressKind: + case schema.AddressKind: return "TEXT" default: return "" diff --git a/indexer/postgres/enum.go b/indexer/postgres/enum.go index c438257d2020..709fc9039562 100644 --- a/indexer/postgres/enum.go +++ b/indexer/postgres/enum.go @@ -11,7 +11,7 @@ import ( ) // CreateEnumType creates an enum type in the database. -func (m *ModuleIndexer) CreateEnumType(ctx context.Context, conn DBConn, enum schema.EnumDefinition) error { +func (m *ModuleIndexer) CreateEnumType(ctx context.Context, conn DBConn, enum schema.EnumType) error { typeName := enumTypeName(m.moduleName, enum) row := conn.QueryRowContext(ctx, "SELECT 1 FROM pg_type WHERE typname = $1", typeName) var res interface{} @@ -39,7 +39,7 @@ func (m *ModuleIndexer) CreateEnumType(ctx context.Context, conn DBConn, enum sc } // CreateEnumTypeSql generates a CREATE TYPE statement for the enum definition. -func CreateEnumTypeSql(writer io.Writer, moduleName string, enum schema.EnumDefinition) error { +func CreateEnumTypeSql(writer io.Writer, moduleName string, enum schema.EnumType) error { _, err := fmt.Fprintf(writer, "CREATE TYPE %q AS ENUM (", enumTypeName(moduleName, enum)) if err != nil { return err @@ -63,30 +63,6 @@ func CreateEnumTypeSql(writer io.Writer, moduleName string, enum schema.EnumDefi } // enumTypeName returns the name of the enum type scoped to the module. -func enumTypeName(moduleName string, enum schema.EnumDefinition) string { +func enumTypeName(moduleName string, enum schema.EnumType) string { return fmt.Sprintf("%s_%s", moduleName, enum.Name) } - -// createEnumTypesForFields creates enum types for all the fields that have enum kind in the module schema. -func (m *ModuleIndexer) createEnumTypesForFields(ctx context.Context, conn DBConn, fields []schema.Field) error { - for _, field := range fields { - if field.Kind != schema.EnumKind { - continue - } - - if _, ok := m.definedEnums[field.EnumDefinition.Name]; ok { - // if the enum type is already defined, skip - // we assume validation already happened - continue - } - - err := m.CreateEnumType(ctx, conn, field.EnumDefinition) - if err != nil { - return err - } - - m.definedEnums[field.EnumDefinition.Name] = field.EnumDefinition - } - - return nil -} diff --git a/indexer/postgres/go.mod b/indexer/postgres/go.mod index d85dbc46718e..b0423dde0744 100644 --- a/indexer/postgres/go.mod +++ b/indexer/postgres/go.mod @@ -9,3 +9,5 @@ go 1.12 // This module should only use the golang standard library (database/sql) // and cosmossdk.io/indexer/base. require cosmossdk.io/schema v0.1.1 + +replace cosmossdk.io/schema => ../../schema diff --git a/indexer/postgres/go.sum b/indexer/postgres/go.sum index 6a92c3d3ec66..e69de29bb2d1 100644 --- a/indexer/postgres/go.sum +++ b/indexer/postgres/go.sum @@ -1,2 +0,0 @@ -cosmossdk.io/schema v0.1.1 h1:I0M6pgI7R10nq+/HCQfbO6BsGBZA8sQy+duR1Y3aKcA= -cosmossdk.io/schema v0.1.1/go.mod h1:RDAhxIeNB4bYqAlF4NBJwRrgtnciMcyyg0DOKnhNZQQ= diff --git a/indexer/postgres/internal/testdata/example_schema.go b/indexer/postgres/internal/testdata/example_schema.go index ccdd39d96c35..ff2d4f2ed1b4 100644 --- a/indexer/postgres/internal/testdata/example_schema.go +++ b/indexer/postgres/internal/testdata/example_schema.go @@ -29,22 +29,26 @@ func init() { switch i { case schema.EnumKind: - field.EnumDefinition = MyEnum - case schema.Bech32AddressKind: - field.AddressPrefix = "foo" + field.EnumType = MyEnum default: } AllKindsObject.ValueFields = append(AllKindsObject.ValueFields, field) } - ExampleSchema = schema.ModuleSchema{ - ObjectTypes: []schema.ObjectType{ - AllKindsObject, - SingletonObject, - VoteObject, - }, + ExampleSchema = mustModuleSchema([]schema.ObjectType{ + AllKindsObject, + SingletonObject, + VoteObject, + }) +} + +func mustModuleSchema(objectTypes []schema.ObjectType) schema.ModuleSchema { + s, err := schema.NewModuleSchema(objectTypes) + if err != nil { + panic(err) } + return s } var SingletonObject = schema.ObjectType{ @@ -60,9 +64,9 @@ var SingletonObject = schema.ObjectType{ Nullable: true, }, { - Name: "an_enum", - Kind: schema.EnumKind, - EnumDefinition: MyEnum, + Name: "an_enum", + Kind: schema.EnumKind, + EnumType: MyEnum, }, }, } @@ -76,14 +80,14 @@ var VoteObject = schema.ObjectType{ }, { Name: "address", - Kind: schema.Bech32AddressKind, + Kind: schema.AddressKind, }, }, ValueFields: []schema.Field{ { Name: "vote", Kind: schema.EnumKind, - EnumDefinition: schema.EnumDefinition{ + EnumType: schema.EnumType{ Name: "vote_type", Values: []string{"yes", "no", "abstain"}, }, @@ -92,7 +96,7 @@ var VoteObject = schema.ObjectType{ RetainDeletions: true, } -var MyEnum = schema.EnumDefinition{ +var MyEnum = schema.EnumType{ Name: "my_enum", Values: []string{"a", "b", "c"}, } diff --git a/indexer/postgres/module.go b/indexer/postgres/module.go index 57564700b78a..0d6a28e2ef72 100644 --- a/indexer/postgres/module.go +++ b/indexer/postgres/module.go @@ -12,7 +12,7 @@ type ModuleIndexer struct { moduleName string schema schema.ModuleSchema tables map[string]*ObjectIndexer - definedEnums map[string]schema.EnumDefinition + definedEnums map[string]schema.EnumType options Options } @@ -22,7 +22,7 @@ func NewModuleIndexer(moduleName string, modSchema schema.ModuleSchema, options moduleName: moduleName, schema: modSchema, tables: map[string]*ObjectIndexer{}, - definedEnums: map[string]schema.EnumDefinition{}, + definedEnums: map[string]schema.EnumType{}, options: options, } } @@ -30,29 +30,27 @@ func NewModuleIndexer(moduleName string, modSchema schema.ModuleSchema, options // InitializeSchema creates tables for all object types in the module schema and creates enum types. func (m *ModuleIndexer) InitializeSchema(ctx context.Context, conn DBConn) error { // create enum types - for _, typ := range m.schema.ObjectTypes { - err := m.createEnumTypesForFields(ctx, conn, typ.KeyFields) - if err != nil { - return err - } - - err = m.createEnumTypesForFields(ctx, conn, typ.ValueFields) - if err != nil { - return err - } + var err error + m.schema.EnumTypes(func(enumType schema.EnumType) bool { + err = m.CreateEnumType(ctx, conn, enumType) + return err == nil + }) + if err != nil { + return err } // create tables for all object types - for _, typ := range m.schema.ObjectTypes { + m.schema.ObjectTypes(func(typ schema.ObjectType) bool { tm := NewObjectIndexer(m.moduleName, typ, m.options) m.tables[typ.Name] = tm - err := tm.CreateTable(ctx, conn) + err = tm.CreateTable(ctx, conn) if err != nil { - return fmt.Errorf("failed to create table for %s in module %s: %v", typ.Name, m.moduleName, err) //nolint:errorlint // using %v for go 1.12 compat + err = fmt.Errorf("failed to create table for %s in module %s: %v", typ.Name, m.moduleName, err) //nolint:errorlint // using %v for go 1.12 compat } - } + return err == nil + }) - return nil + return err } // ObjectIndexers returns the object indexers for the module. diff --git a/indexer/postgres/tests/go.mod b/indexer/postgres/tests/go.mod index d5a29304251f..0353ba6091b5 100644 --- a/indexer/postgres/tests/go.mod +++ b/indexer/postgres/tests/go.mod @@ -30,4 +30,6 @@ require ( replace cosmossdk.io/indexer/postgres => ../. +replace cosmossdk.io/schema => ../../../schema + go 1.22 diff --git a/indexer/postgres/tests/go.sum b/indexer/postgres/tests/go.sum index a4ba87b486c2..de3d49d74702 100644 --- a/indexer/postgres/tests/go.sum +++ b/indexer/postgres/tests/go.sum @@ -1,5 +1,3 @@ -cosmossdk.io/schema v0.1.1 h1:I0M6pgI7R10nq+/HCQfbO6BsGBZA8sQy+duR1Y3aKcA= -cosmossdk.io/schema v0.1.1/go.mod h1:RDAhxIeNB4bYqAlF4NBJwRrgtnciMcyyg0DOKnhNZQQ= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM= From b6eaf70b6af08e8b6904f853defe5ecd65332264 Mon Sep 17 00:00:00 2001 From: Hieu Vu <72878483+hieuvubk@users.noreply.github.com> Date: Fri, 26 Jul 2024 03:50:57 +0700 Subject: [PATCH 49/50] feat(simapp/v2): Add store server to testnet init cmd (#21076) --- scripts/local-testnet.sh | 2 +- simapp/v2/simdv2/cmd/testnet.go | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/scripts/local-testnet.sh b/scripts/local-testnet.sh index c73710dbab1e..c3e1162a6aae 100644 --- a/scripts/local-testnet.sh +++ b/scripts/local-testnet.sh @@ -10,7 +10,7 @@ SIMD="$ROOT/build/simdv2" COSMOS_BUILD_OPTIONS=v2 make build -$SIMD testnet init-files --chain-id=testing --output-dir="$HOME/.testnet" --validator-count=3 --keyring-backend=test --minimum-gas-prices=0.000001stake --commit-timeout=900ms --single-host +$SIMD testnet init-files --chain-id=testing --output-dir="$HOME/.testnet" --validator-count=3 --keyring-backend=test --min-gas-prices=0.000001stake --commit-timeout=900ms --single-host $SIMD start --log_level=info --home "$HOME/.testnet/node0/simdv2" & $SIMD start --log_level=info --home "$HOME/.testnet/node1/simdv2" & diff --git a/simapp/v2/simdv2/cmd/testnet.go b/simapp/v2/simdv2/cmd/testnet.go index b0a755a97190..e07ce2582459 100644 --- a/simapp/v2/simdv2/cmd/testnet.go +++ b/simapp/v2/simdv2/cmd/testnet.go @@ -22,6 +22,7 @@ import ( serverv2 "cosmossdk.io/server/v2" "cosmossdk.io/server/v2/api/grpc" "cosmossdk.io/server/v2/cometbft" + "cosmossdk.io/server/v2/store" authtypes "cosmossdk.io/x/auth/types" banktypes "cosmossdk.io/x/bank/types" stakingtypes "cosmossdk.io/x/staking/types" @@ -343,7 +344,8 @@ func initTestnetFiles[T transaction.Tx]( cometbft.OverwriteDefaultConfigTomlConfig(nodeConfig), ) grpcServer := grpc.New[T](grpc.OverwriteDefaultConfig(grpcConfig)) - server := serverv2.NewServer(coretesting.NewNopLogger(), cometServer, grpcServer) + storeServer := store.New[T]() + server := serverv2.NewServer(coretesting.NewNopLogger(), cometServer, grpcServer, storeServer) err = server.WriteConfig(filepath.Join(nodeDir, "config")) if err != nil { return err From 502450cd1ef0b6bd77807922091893611c370c5d Mon Sep 17 00:00:00 2001 From: Julien Robert Date: Thu, 25 Jul 2024 23:43:19 +0200 Subject: [PATCH 50/50] fix(runtime): remove `appv1alpha1.Config` from runtime (#21042) --- runtime/app.go | 2 -- runtime/module.go | 3 --- runtime/v2/app.go | 6 ++---- runtime/v2/module.go | 2 -- 4 files changed, 2 insertions(+), 11 deletions(-) diff --git a/runtime/app.go b/runtime/app.go index 80bc28340898..aeef32a28db8 100644 --- a/runtime/app.go +++ b/runtime/app.go @@ -8,7 +8,6 @@ import ( abci "github.com/cometbft/cometbft/api/cometbft/abci/v1" runtimev1alpha1 "cosmossdk.io/api/cosmos/app/runtime/v1alpha1" - appv1alpha1 "cosmossdk.io/api/cosmos/app/v1alpha1" "cosmossdk.io/core/appmodule" "cosmossdk.io/core/legacy" "cosmossdk.io/core/log" @@ -51,7 +50,6 @@ type App struct { baseAppOptions []BaseAppOption msgServiceRouter *baseapp.MsgServiceRouter grpcQueryRouter *baseapp.GRPCQueryRouter - appConfig *appv1alpha1.Config logger log.Logger // initChainer is the init chainer function defined by the app config. // this is only required if the chain wants to add special InitChainer logic. diff --git a/runtime/module.go b/runtime/module.go index 501b9c1ff04c..1060a9857b85 100644 --- a/runtime/module.go +++ b/runtime/module.go @@ -10,7 +10,6 @@ import ( "google.golang.org/protobuf/reflect/protoregistry" runtimev1alpha1 "cosmossdk.io/api/cosmos/app/runtime/v1alpha1" - appv1alpha1 "cosmossdk.io/api/cosmos/app/v1alpha1" autocliv1 "cosmossdk.io/api/cosmos/autocli/v1" reflectionv1 "cosmossdk.io/api/cosmos/reflection/v1" "cosmossdk.io/core/app" @@ -155,7 +154,6 @@ type AppInputs struct { depinject.In Logger log.Logger - AppConfig *appv1alpha1.Config Config *runtimev1alpha1.Module AppBuilder *AppBuilder ModuleManager *module.Manager @@ -168,7 +166,6 @@ func SetupAppBuilder(inputs AppInputs) { app := inputs.AppBuilder.app app.baseAppOptions = inputs.BaseAppOptions app.config = inputs.Config - app.appConfig = inputs.AppConfig app.logger = inputs.Logger app.ModuleManager = inputs.ModuleManager app.ModuleManager.RegisterInterfaces(inputs.InterfaceRegistry) diff --git a/runtime/v2/app.go b/runtime/v2/app.go index 89d6d0be24ba..56632590b4f9 100644 --- a/runtime/v2/app.go +++ b/runtime/v2/app.go @@ -8,7 +8,6 @@ import ( "golang.org/x/exp/slices" runtimev2 "cosmossdk.io/api/cosmos/app/runtime/v2" - appv1alpha1 "cosmossdk.io/api/cosmos/app/v1alpha1" "cosmossdk.io/core/legacy" "cosmossdk.io/core/log" "cosmossdk.io/core/registry" @@ -36,9 +35,8 @@ type App[T transaction.Tx] struct { db Store // app configuration - logger log.Logger - config *runtimev2.Module - appConfig *appv1alpha1.Config + logger log.Logger + config *runtimev2.Module // modules configuration storeKeys []string diff --git a/runtime/v2/module.go b/runtime/v2/module.go index cb0ec169d315..588584d06500 100644 --- a/runtime/v2/module.go +++ b/runtime/v2/module.go @@ -144,7 +144,6 @@ func ProvideAppBuilder[T transaction.Tx]( type AppInputs struct { depinject.In - AppConfig *appv1alpha1.Config Config *runtimev2.Module AppBuilder *AppBuilder[transaction.Tx] ModuleManager *MM[transaction.Tx] @@ -157,7 +156,6 @@ type AppInputs struct { func SetupAppBuilder(inputs AppInputs) { app := inputs.AppBuilder.app app.config = inputs.Config - app.appConfig = inputs.AppConfig app.logger = inputs.Logger app.moduleManager = inputs.ModuleManager app.moduleManager.RegisterInterfaces(inputs.InterfaceRegistrar)