diff --git a/UPGRADING.md b/UPGRADING.md index 6c079ac1ce37..491299c8f493 100644 --- a/UPGRADING.md +++ b/UPGRADING.md @@ -9,6 +9,7 @@ Note, always read the **SimApp** section for more information on application wir In this section we describe the changes made in Cosmos SDK' SimApp. **These changes are directly applicable to your application wiring.** +Please read this section first, but for an exhaustive list of changes, refer to the [CHANGELOG](./simapp/CHANGELOG.md). #### Client (`root.go`) @@ -145,6 +146,23 @@ used as a TTL for the transaction and is used to provide replay protection. See [ADR-070](https://github.com/cosmos/cosmos-sdk/blob/main/docs/architecture/adr-070-unordered-transactions.md) for more details. +### Depinject `app_config.go` / `app.yml` + +With the introduction of [environment in modules](#core-api), depinject automatically creates the environment for all modules. +Learn more about environment [here](https://example.com) . Given the fields of environment, this means runtime creates a kv store service for all modules by default. +It can happen that some modules do not have a store necessary (such as `x/auth/tx` for instance). In this case, the store creation should be skipped in `app_config.go`: + +```diff +InitGenesis: []string{ + "..." +}, ++ // SkipStoreKeys is an optional list of store keys to skip when constructing the ++ // module's keeper. This is useful when a module does not have a store key. ++ SkipStoreKeys: []string{ ++ "tx", ++ }, +``` + ### Protobuf The `cosmossdk.io/api/tendermint` package has been removed as CometBFT now publishes its protos to `buf.build/tendermint` and `buf.build/cometbft`. @@ -203,7 +221,7 @@ been added to avoid the use of the Accounts.String() method. +type MsgSimulatorFn func(r *rand.Rand, accs []Account, cdc address.Codec) (sdk.Msg, error) ``` -##### Dependency Injection +##### Depinject Previously `cosmossdk.io/core` held functions `Invoke`, `Provide` and `Register` were moved to `cosmossdk.io/depinject/appconfig`. All modules using dependency injection must update their imports. diff --git a/api/cosmos/app/runtime/v1alpha1/module.pulsar.go b/api/cosmos/app/runtime/v1alpha1/module.pulsar.go index 14cb9784ab31..c1da19eccf67 100644 --- a/api/cosmos/app/runtime/v1alpha1/module.pulsar.go +++ b/api/cosmos/app/runtime/v1alpha1/module.pulsar.go @@ -248,6 +248,52 @@ func (x *_Module_6_list) IsValid() bool { return x.list != nil } +var _ protoreflect.List = (*_Module_11_list)(nil) + +type _Module_11_list struct { + list *[]string +} + +func (x *_Module_11_list) Len() int { + if x.list == nil { + return 0 + } + return len(*x.list) +} + +func (x *_Module_11_list) Get(i int) protoreflect.Value { + return protoreflect.ValueOfString((*x.list)[i]) +} + +func (x *_Module_11_list) Set(i int, value protoreflect.Value) { + valueUnwrapped := value.String() + concreteValue := valueUnwrapped + (*x.list)[i] = concreteValue +} + +func (x *_Module_11_list) Append(value protoreflect.Value) { + valueUnwrapped := value.String() + concreteValue := valueUnwrapped + *x.list = append(*x.list, concreteValue) +} + +func (x *_Module_11_list) AppendMutable() protoreflect.Value { + panic(fmt.Errorf("AppendMutable can not be called on message Module at list field SkipStoreKeys as it is not of Message kind")) +} + +func (x *_Module_11_list) Truncate(n int) { + *x.list = (*x.list)[:n] +} + +func (x *_Module_11_list) NewElement() protoreflect.Value { + v := "" + return protoreflect.ValueOfString(v) +} + +func (x *_Module_11_list) IsValid() bool { + return x.list != nil +} + var _ protoreflect.List = (*_Module_7_list)(nil) type _Module_7_list struct { @@ -440,6 +486,7 @@ var ( fd_Module_init_genesis protoreflect.FieldDescriptor fd_Module_export_genesis protoreflect.FieldDescriptor fd_Module_override_store_keys protoreflect.FieldDescriptor + fd_Module_skip_store_keys protoreflect.FieldDescriptor fd_Module_order_migrations protoreflect.FieldDescriptor fd_Module_precommiters protoreflect.FieldDescriptor fd_Module_prepare_check_staters protoreflect.FieldDescriptor @@ -455,6 +502,7 @@ func init() { fd_Module_init_genesis = md_Module.Fields().ByName("init_genesis") fd_Module_export_genesis = md_Module.Fields().ByName("export_genesis") fd_Module_override_store_keys = md_Module.Fields().ByName("override_store_keys") + fd_Module_skip_store_keys = md_Module.Fields().ByName("skip_store_keys") fd_Module_order_migrations = md_Module.Fields().ByName("order_migrations") fd_Module_precommiters = md_Module.Fields().ByName("precommiters") fd_Module_prepare_check_staters = md_Module.Fields().ByName("prepare_check_staters") @@ -562,6 +610,12 @@ func (x *fastReflection_Module) Range(f func(protoreflect.FieldDescriptor, proto return } } + if len(x.SkipStoreKeys) != 0 { + value := protoreflect.ValueOfList(&_Module_11_list{list: &x.SkipStoreKeys}) + if !f(fd_Module_skip_store_keys, value) { + return + } + } if len(x.OrderMigrations) != 0 { value := protoreflect.ValueOfList(&_Module_7_list{list: &x.OrderMigrations}) if !f(fd_Module_order_migrations, value) { @@ -613,6 +667,8 @@ func (x *fastReflection_Module) Has(fd protoreflect.FieldDescriptor) bool { return len(x.ExportGenesis) != 0 case "cosmos.app.runtime.v1alpha1.Module.override_store_keys": return len(x.OverrideStoreKeys) != 0 + case "cosmos.app.runtime.v1alpha1.Module.skip_store_keys": + return len(x.SkipStoreKeys) != 0 case "cosmos.app.runtime.v1alpha1.Module.order_migrations": return len(x.OrderMigrations) != 0 case "cosmos.app.runtime.v1alpha1.Module.precommiters": @@ -649,6 +705,8 @@ func (x *fastReflection_Module) Clear(fd protoreflect.FieldDescriptor) { x.ExportGenesis = nil case "cosmos.app.runtime.v1alpha1.Module.override_store_keys": x.OverrideStoreKeys = nil + case "cosmos.app.runtime.v1alpha1.Module.skip_store_keys": + x.SkipStoreKeys = nil case "cosmos.app.runtime.v1alpha1.Module.order_migrations": x.OrderMigrations = nil case "cosmos.app.runtime.v1alpha1.Module.precommiters": @@ -706,6 +764,12 @@ func (x *fastReflection_Module) Get(descriptor protoreflect.FieldDescriptor) pro } listValue := &_Module_6_list{list: &x.OverrideStoreKeys} return protoreflect.ValueOfList(listValue) + case "cosmos.app.runtime.v1alpha1.Module.skip_store_keys": + if len(x.SkipStoreKeys) == 0 { + return protoreflect.ValueOfList(&_Module_11_list{}) + } + listValue := &_Module_11_list{list: &x.SkipStoreKeys} + return protoreflect.ValueOfList(listValue) case "cosmos.app.runtime.v1alpha1.Module.order_migrations": if len(x.OrderMigrations) == 0 { return protoreflect.ValueOfList(&_Module_7_list{}) @@ -772,6 +836,10 @@ func (x *fastReflection_Module) Set(fd protoreflect.FieldDescriptor, value proto lv := value.List() clv := lv.(*_Module_6_list) x.OverrideStoreKeys = *clv.list + case "cosmos.app.runtime.v1alpha1.Module.skip_store_keys": + lv := value.List() + clv := lv.(*_Module_11_list) + x.SkipStoreKeys = *clv.list case "cosmos.app.runtime.v1alpha1.Module.order_migrations": lv := value.List() clv := lv.(*_Module_7_list) @@ -838,6 +906,12 @@ func (x *fastReflection_Module) Mutable(fd protoreflect.FieldDescriptor) protore } value := &_Module_6_list{list: &x.OverrideStoreKeys} return protoreflect.ValueOfList(value) + case "cosmos.app.runtime.v1alpha1.Module.skip_store_keys": + if x.SkipStoreKeys == nil { + x.SkipStoreKeys = []string{} + } + value := &_Module_11_list{list: &x.SkipStoreKeys} + return protoreflect.ValueOfList(value) case "cosmos.app.runtime.v1alpha1.Module.order_migrations": if x.OrderMigrations == nil { x.OrderMigrations = []string{} @@ -894,6 +968,9 @@ func (x *fastReflection_Module) NewField(fd protoreflect.FieldDescriptor) protor case "cosmos.app.runtime.v1alpha1.Module.override_store_keys": list := []*StoreKeyConfig{} return protoreflect.ValueOfList(&_Module_6_list{list: &list}) + case "cosmos.app.runtime.v1alpha1.Module.skip_store_keys": + list := []string{} + return protoreflect.ValueOfList(&_Module_11_list{list: &list}) case "cosmos.app.runtime.v1alpha1.Module.order_migrations": list := []string{} return protoreflect.ValueOfList(&_Module_7_list{list: &list}) @@ -1009,6 +1086,12 @@ func (x *fastReflection_Module) ProtoMethods() *protoiface.Methods { n += 1 + l + runtime.Sov(uint64(l)) } } + if len(x.SkipStoreKeys) > 0 { + for _, s := range x.SkipStoreKeys { + l = len(s) + n += 1 + l + runtime.Sov(uint64(l)) + } + } if len(x.OrderMigrations) > 0 { for _, s := range x.OrderMigrations { l = len(s) @@ -1062,6 +1145,15 @@ func (x *fastReflection_Module) ProtoMethods() *protoiface.Methods { i -= len(x.unknownFields) copy(dAtA[i:], x.unknownFields) } + if len(x.SkipStoreKeys) > 0 { + for iNdEx := len(x.SkipStoreKeys) - 1; iNdEx >= 0; iNdEx-- { + i -= len(x.SkipStoreKeys[iNdEx]) + copy(dAtA[i:], x.SkipStoreKeys[iNdEx]) + i = runtime.EncodeVarint(dAtA, i, uint64(len(x.SkipStoreKeys[iNdEx]))) + i-- + dAtA[i] = 0x5a + } + } if len(x.PreBlockers) > 0 { for iNdEx := len(x.PreBlockers) - 1; iNdEx >= 0; iNdEx-- { i -= len(x.PreBlockers[iNdEx]) @@ -1400,6 +1492,38 @@ func (x *fastReflection_Module) ProtoMethods() *protoiface.Methods { return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err } iNdEx = postIndex + case 11: + if wireType != 2 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field SkipStoreKeys", 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.SkipStoreKeys = append(x.SkipStoreKeys, string(dAtA[iNdEx:postIndex])) + iNdEx = postIndex case 7: if wireType != 2 { return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field OrderMigrations", wireType) @@ -2087,6 +2211,10 @@ type Module struct { // override_store_keys is an optional list of overrides for the module store keys // to be used in keeper construction. OverrideStoreKeys []*StoreKeyConfig `protobuf:"bytes,6,rep,name=override_store_keys,json=overrideStoreKeys,proto3" json:"override_store_keys,omitempty"` + // skip_store_keys is an optional list of store keys to skip when constructing the + // module's keeper. This is useful when a module does not have a store key. + // NOTE: the provided environment variable will have a fake store service. + SkipStoreKeys []string `protobuf:"bytes,11,rep,name=skip_store_keys,json=skipStoreKeys,proto3" json:"skip_store_keys,omitempty"` // order_migrations defines the order in which module migrations are performed. // If this is left empty, it uses the default migration order. // https://pkg.go.dev/github.com/cosmos/cosmos-sdk@v0.47.0-alpha2/types/module#DefaultMigrationsOrder @@ -2167,6 +2295,13 @@ func (x *Module) GetOverrideStoreKeys() []*StoreKeyConfig { return nil } +func (x *Module) GetSkipStoreKeys() []string { + if x != nil { + return x.SkipStoreKeys + } + return nil +} + func (x *Module) GetOrderMigrations() []string { if x != nil { return x.OrderMigrations @@ -2251,7 +2386,7 @@ var file_cosmos_app_runtime_v1alpha1_module_proto_rawDesc = []byte{ 0x6f, 0x73, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x72, 0x75, 0x6e, 0x74, 0x69, 0x6d, 0x65, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x1a, 0x20, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x61, 0x70, 0x70, 0x2f, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2f, 0x6d, 0x6f, 0x64, - 0x75, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xff, 0x03, 0x0a, 0x06, 0x4d, 0x6f, + 0x75, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xa7, 0x04, 0x0a, 0x06, 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x12, 0x19, 0x0a, 0x08, 0x61, 0x70, 0x70, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x61, 0x70, 0x70, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x25, 0x0a, 0x0e, 0x62, 0x65, 0x67, 0x69, 0x6e, 0x5f, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x65, 0x72, @@ -2269,43 +2404,45 @@ var file_cosmos_app_runtime_v1alpha1_module_proto_rawDesc = []byte{ 0x6e, 0x74, 0x69, 0x6d, 0x65, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x53, 0x74, 0x6f, 0x72, 0x65, 0x4b, 0x65, 0x79, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x11, 0x6f, 0x76, 0x65, 0x72, 0x72, 0x69, 0x64, 0x65, 0x53, 0x74, 0x6f, 0x72, 0x65, 0x4b, 0x65, 0x79, 0x73, - 0x12, 0x29, 0x0a, 0x10, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x5f, 0x6d, 0x69, 0x67, 0x72, 0x61, 0x74, - 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x07, 0x20, 0x03, 0x28, 0x09, 0x52, 0x0f, 0x6f, 0x72, 0x64, 0x65, - 0x72, 0x4d, 0x69, 0x67, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x22, 0x0a, 0x0c, 0x70, - 0x72, 0x65, 0x63, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x65, 0x72, 0x73, 0x18, 0x08, 0x20, 0x03, 0x28, - 0x09, 0x52, 0x0c, 0x70, 0x72, 0x65, 0x63, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x65, 0x72, 0x73, 0x12, - 0x32, 0x0a, 0x15, 0x70, 0x72, 0x65, 0x70, 0x61, 0x72, 0x65, 0x5f, 0x63, 0x68, 0x65, 0x63, 0x6b, - 0x5f, 0x73, 0x74, 0x61, 0x74, 0x65, 0x72, 0x73, 0x18, 0x09, 0x20, 0x03, 0x28, 0x09, 0x52, 0x13, - 0x70, 0x72, 0x65, 0x70, 0x61, 0x72, 0x65, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x53, 0x74, 0x61, 0x74, - 0x65, 0x72, 0x73, 0x12, 0x21, 0x0a, 0x0c, 0x70, 0x72, 0x65, 0x5f, 0x62, 0x6c, 0x6f, 0x63, 0x6b, - 0x65, 0x72, 0x73, 0x18, 0x0a, 0x20, 0x03, 0x28, 0x09, 0x52, 0x0b, 0x70, 0x72, 0x65, 0x42, 0x6c, - 0x6f, 0x63, 0x6b, 0x65, 0x72, 0x73, 0x3a, 0x43, 0xba, 0xc0, 0x96, 0xda, 0x01, 0x3d, 0x0a, 0x24, - 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, - 0x73, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2d, 0x73, 0x64, 0x6b, 0x2f, 0x72, 0x75, 0x6e, - 0x74, 0x69, 0x6d, 0x65, 0x12, 0x15, 0x0a, 0x13, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x61, - 0x70, 0x70, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x22, 0x53, 0x0a, 0x0e, 0x53, - 0x74, 0x6f, 0x72, 0x65, 0x4b, 0x65, 0x79, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x1f, 0x0a, - 0x0b, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x0a, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x20, - 0x0a, 0x0c, 0x6b, 0x76, 0x5f, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x5f, 0x6b, 0x65, 0x79, 0x18, 0x02, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x6b, 0x76, 0x53, 0x74, 0x6f, 0x72, 0x65, 0x4b, 0x65, 0x79, - 0x42, 0xfb, 0x01, 0x0a, 0x1f, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, - 0x61, 0x70, 0x70, 0x2e, 0x72, 0x75, 0x6e, 0x74, 0x69, 0x6d, 0x65, 0x2e, 0x76, 0x31, 0x61, 0x6c, - 0x70, 0x68, 0x61, 0x31, 0x42, 0x0b, 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x50, 0x72, 0x6f, 0x74, - 0x6f, 0x50, 0x01, 0x5a, 0x3c, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, - 0x6f, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x61, 0x70, 0x70, - 0x2f, 0x72, 0x75, 0x6e, 0x74, 0x69, 0x6d, 0x65, 0x2f, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, - 0x31, 0x3b, 0x72, 0x75, 0x6e, 0x74, 0x69, 0x6d, 0x65, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, - 0x31, 0xa2, 0x02, 0x03, 0x43, 0x41, 0x52, 0xaa, 0x02, 0x1b, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, - 0x2e, 0x41, 0x70, 0x70, 0x2e, 0x52, 0x75, 0x6e, 0x74, 0x69, 0x6d, 0x65, 0x2e, 0x56, 0x31, 0x61, - 0x6c, 0x70, 0x68, 0x61, 0x31, 0xca, 0x02, 0x1b, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x5c, 0x41, - 0x70, 0x70, 0x5c, 0x52, 0x75, 0x6e, 0x74, 0x69, 0x6d, 0x65, 0x5c, 0x56, 0x31, 0x61, 0x6c, 0x70, - 0x68, 0x61, 0x31, 0xe2, 0x02, 0x27, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x5c, 0x41, 0x70, 0x70, - 0x5c, 0x52, 0x75, 0x6e, 0x74, 0x69, 0x6d, 0x65, 0x5c, 0x56, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, - 0x31, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x1e, - 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x3a, 0x3a, 0x41, 0x70, 0x70, 0x3a, 0x3a, 0x52, 0x75, 0x6e, - 0x74, 0x69, 0x6d, 0x65, 0x3a, 0x3a, 0x56, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x62, 0x06, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x12, 0x26, 0x0a, 0x0f, 0x73, 0x6b, 0x69, 0x70, 0x5f, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x5f, 0x6b, + 0x65, 0x79, 0x73, 0x18, 0x0b, 0x20, 0x03, 0x28, 0x09, 0x52, 0x0d, 0x73, 0x6b, 0x69, 0x70, 0x53, + 0x74, 0x6f, 0x72, 0x65, 0x4b, 0x65, 0x79, 0x73, 0x12, 0x29, 0x0a, 0x10, 0x6f, 0x72, 0x64, 0x65, + 0x72, 0x5f, 0x6d, 0x69, 0x67, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x07, 0x20, 0x03, + 0x28, 0x09, 0x52, 0x0f, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x4d, 0x69, 0x67, 0x72, 0x61, 0x74, 0x69, + 0x6f, 0x6e, 0x73, 0x12, 0x22, 0x0a, 0x0c, 0x70, 0x72, 0x65, 0x63, 0x6f, 0x6d, 0x6d, 0x69, 0x74, + 0x65, 0x72, 0x73, 0x18, 0x08, 0x20, 0x03, 0x28, 0x09, 0x52, 0x0c, 0x70, 0x72, 0x65, 0x63, 0x6f, + 0x6d, 0x6d, 0x69, 0x74, 0x65, 0x72, 0x73, 0x12, 0x32, 0x0a, 0x15, 0x70, 0x72, 0x65, 0x70, 0x61, + 0x72, 0x65, 0x5f, 0x63, 0x68, 0x65, 0x63, 0x6b, 0x5f, 0x73, 0x74, 0x61, 0x74, 0x65, 0x72, 0x73, + 0x18, 0x09, 0x20, 0x03, 0x28, 0x09, 0x52, 0x13, 0x70, 0x72, 0x65, 0x70, 0x61, 0x72, 0x65, 0x43, + 0x68, 0x65, 0x63, 0x6b, 0x53, 0x74, 0x61, 0x74, 0x65, 0x72, 0x73, 0x12, 0x21, 0x0a, 0x0c, 0x70, + 0x72, 0x65, 0x5f, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x65, 0x72, 0x73, 0x18, 0x0a, 0x20, 0x03, 0x28, + 0x09, 0x52, 0x0b, 0x70, 0x72, 0x65, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x65, 0x72, 0x73, 0x3a, 0x43, + 0xba, 0xc0, 0x96, 0xda, 0x01, 0x3d, 0x0a, 0x24, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, + 0x6f, 0x6d, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, + 0x2d, 0x73, 0x64, 0x6b, 0x2f, 0x72, 0x75, 0x6e, 0x74, 0x69, 0x6d, 0x65, 0x12, 0x15, 0x0a, 0x13, + 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, + 0x68, 0x61, 0x31, 0x22, 0x53, 0x0a, 0x0e, 0x53, 0x74, 0x6f, 0x72, 0x65, 0x4b, 0x65, 0x79, 0x43, + 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x1f, 0x0a, 0x0b, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x5f, + 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x6d, 0x6f, 0x64, 0x75, + 0x6c, 0x65, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x20, 0x0a, 0x0c, 0x6b, 0x76, 0x5f, 0x73, 0x74, 0x6f, + 0x72, 0x65, 0x5f, 0x6b, 0x65, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x6b, 0x76, + 0x53, 0x74, 0x6f, 0x72, 0x65, 0x4b, 0x65, 0x79, 0x42, 0xfb, 0x01, 0x0a, 0x1f, 0x63, 0x6f, 0x6d, + 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x72, 0x75, 0x6e, 0x74, + 0x69, 0x6d, 0x65, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x42, 0x0b, 0x4d, 0x6f, + 0x64, 0x75, 0x6c, 0x65, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x3c, 0x63, 0x6f, 0x73, + 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6f, + 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x61, 0x70, 0x70, 0x2f, 0x72, 0x75, 0x6e, 0x74, 0x69, 0x6d, 0x65, + 0x2f, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x3b, 0x72, 0x75, 0x6e, 0x74, 0x69, 0x6d, + 0x65, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0xa2, 0x02, 0x03, 0x43, 0x41, 0x52, 0xaa, + 0x02, 0x1b, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x41, 0x70, 0x70, 0x2e, 0x52, 0x75, 0x6e, + 0x74, 0x69, 0x6d, 0x65, 0x2e, 0x56, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0xca, 0x02, 0x1b, + 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x5c, 0x41, 0x70, 0x70, 0x5c, 0x52, 0x75, 0x6e, 0x74, 0x69, + 0x6d, 0x65, 0x5c, 0x56, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0xe2, 0x02, 0x27, 0x43, 0x6f, + 0x73, 0x6d, 0x6f, 0x73, 0x5c, 0x41, 0x70, 0x70, 0x5c, 0x52, 0x75, 0x6e, 0x74, 0x69, 0x6d, 0x65, + 0x5c, 0x56, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, + 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x1e, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x3a, 0x3a, + 0x41, 0x70, 0x70, 0x3a, 0x3a, 0x52, 0x75, 0x6e, 0x74, 0x69, 0x6d, 0x65, 0x3a, 0x3a, 0x56, 0x31, + 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/api/cosmos/app/runtime/v2/module.pulsar.go b/api/cosmos/app/runtime/v2/module.pulsar.go index e65b4cc69026..8c90f1df8917 100644 --- a/api/cosmos/app/runtime/v2/module.pulsar.go +++ b/api/cosmos/app/runtime/v2/module.pulsar.go @@ -386,6 +386,52 @@ func (x *_Module_10_list) IsValid() bool { return x.list != nil } +var _ protoreflect.List = (*_Module_11_list)(nil) + +type _Module_11_list struct { + list *[]string +} + +func (x *_Module_11_list) Len() int { + if x.list == nil { + return 0 + } + return len(*x.list) +} + +func (x *_Module_11_list) Get(i int) protoreflect.Value { + return protoreflect.ValueOfString((*x.list)[i]) +} + +func (x *_Module_11_list) Set(i int, value protoreflect.Value) { + valueUnwrapped := value.String() + concreteValue := valueUnwrapped + (*x.list)[i] = concreteValue +} + +func (x *_Module_11_list) Append(value protoreflect.Value) { + valueUnwrapped := value.String() + concreteValue := valueUnwrapped + *x.list = append(*x.list, concreteValue) +} + +func (x *_Module_11_list) AppendMutable() protoreflect.Value { + panic(fmt.Errorf("AppendMutable can not be called on message Module at list field SkipStoreKeys as it is not of Message kind")) +} + +func (x *_Module_11_list) Truncate(n int) { + *x.list = (*x.list)[:n] +} + +func (x *_Module_11_list) NewElement() protoreflect.Value { + v := "" + return protoreflect.ValueOfString(v) +} + +func (x *_Module_11_list) IsValid() bool { + return x.list != nil +} + var ( md_Module protoreflect.MessageDescriptor fd_Module_app_name protoreflect.FieldDescriptor @@ -398,6 +444,7 @@ var ( fd_Module_order_migrations protoreflect.FieldDescriptor fd_Module_gas_config protoreflect.FieldDescriptor fd_Module_override_store_keys protoreflect.FieldDescriptor + fd_Module_skip_store_keys protoreflect.FieldDescriptor ) func init() { @@ -413,6 +460,7 @@ func init() { fd_Module_order_migrations = md_Module.Fields().ByName("order_migrations") fd_Module_gas_config = md_Module.Fields().ByName("gas_config") fd_Module_override_store_keys = md_Module.Fields().ByName("override_store_keys") + fd_Module_skip_store_keys = md_Module.Fields().ByName("skip_store_keys") } var _ protoreflect.Message = (*fastReflection_Module)(nil) @@ -540,6 +588,12 @@ func (x *fastReflection_Module) Range(f func(protoreflect.FieldDescriptor, proto return } } + if len(x.SkipStoreKeys) != 0 { + value := protoreflect.ValueOfList(&_Module_11_list{list: &x.SkipStoreKeys}) + if !f(fd_Module_skip_store_keys, value) { + return + } + } } // Has reports whether a field is populated. @@ -575,6 +629,8 @@ func (x *fastReflection_Module) Has(fd protoreflect.FieldDescriptor) bool { return x.GasConfig != nil case "cosmos.app.runtime.v2.Module.override_store_keys": return len(x.OverrideStoreKeys) != 0 + case "cosmos.app.runtime.v2.Module.skip_store_keys": + return len(x.SkipStoreKeys) != 0 default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.app.runtime.v2.Module")) @@ -611,6 +667,8 @@ func (x *fastReflection_Module) Clear(fd protoreflect.FieldDescriptor) { x.GasConfig = nil case "cosmos.app.runtime.v2.Module.override_store_keys": x.OverrideStoreKeys = nil + case "cosmos.app.runtime.v2.Module.skip_store_keys": + x.SkipStoreKeys = nil default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.app.runtime.v2.Module")) @@ -681,6 +739,12 @@ func (x *fastReflection_Module) Get(descriptor protoreflect.FieldDescriptor) pro } listValue := &_Module_10_list{list: &x.OverrideStoreKeys} return protoreflect.ValueOfList(listValue) + case "cosmos.app.runtime.v2.Module.skip_store_keys": + if len(x.SkipStoreKeys) == 0 { + return protoreflect.ValueOfList(&_Module_11_list{}) + } + listValue := &_Module_11_list{list: &x.SkipStoreKeys} + return protoreflect.ValueOfList(listValue) default: if descriptor.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.app.runtime.v2.Module")) @@ -737,6 +801,10 @@ func (x *fastReflection_Module) Set(fd protoreflect.FieldDescriptor, value proto lv := value.List() clv := lv.(*_Module_10_list) x.OverrideStoreKeys = *clv.list + case "cosmos.app.runtime.v2.Module.skip_store_keys": + lv := value.List() + clv := lv.(*_Module_11_list) + x.SkipStoreKeys = *clv.list default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.app.runtime.v2.Module")) @@ -810,6 +878,12 @@ func (x *fastReflection_Module) Mutable(fd protoreflect.FieldDescriptor) protore } value := &_Module_10_list{list: &x.OverrideStoreKeys} return protoreflect.ValueOfList(value) + case "cosmos.app.runtime.v2.Module.skip_store_keys": + if x.SkipStoreKeys == nil { + x.SkipStoreKeys = []string{} + } + value := &_Module_11_list{list: &x.SkipStoreKeys} + return protoreflect.ValueOfList(value) case "cosmos.app.runtime.v2.Module.app_name": panic(fmt.Errorf("field app_name of message cosmos.app.runtime.v2.Module is not mutable")) default: @@ -854,6 +928,9 @@ func (x *fastReflection_Module) NewField(fd protoreflect.FieldDescriptor) protor case "cosmos.app.runtime.v2.Module.override_store_keys": list := []*StoreKeyConfig{} return protoreflect.ValueOfList(&_Module_10_list{list: &list}) + case "cosmos.app.runtime.v2.Module.skip_store_keys": + list := []string{} + return protoreflect.ValueOfList(&_Module_11_list{list: &list}) default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.app.runtime.v2.Module")) @@ -979,6 +1056,12 @@ func (x *fastReflection_Module) ProtoMethods() *protoiface.Methods { n += 1 + l + runtime.Sov(uint64(l)) } } + if len(x.SkipStoreKeys) > 0 { + for _, s := range x.SkipStoreKeys { + l = len(s) + n += 1 + l + runtime.Sov(uint64(l)) + } + } if x.unknownFields != nil { n += len(x.unknownFields) } @@ -1008,6 +1091,15 @@ func (x *fastReflection_Module) ProtoMethods() *protoiface.Methods { i -= len(x.unknownFields) copy(dAtA[i:], x.unknownFields) } + if len(x.SkipStoreKeys) > 0 { + for iNdEx := len(x.SkipStoreKeys) - 1; iNdEx >= 0; iNdEx-- { + i -= len(x.SkipStoreKeys[iNdEx]) + copy(dAtA[i:], x.SkipStoreKeys[iNdEx]) + i = runtime.EncodeVarint(dAtA, i, uint64(len(x.SkipStoreKeys[iNdEx]))) + i-- + dAtA[i] = 0x5a + } + } if len(x.OverrideStoreKeys) > 0 { for iNdEx := len(x.OverrideStoreKeys) - 1; iNdEx >= 0; iNdEx-- { encoded, err := options.Marshal(x.OverrideStoreKeys[iNdEx]) @@ -1483,6 +1575,38 @@ func (x *fastReflection_Module) ProtoMethods() *protoiface.Methods { return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err } iNdEx = postIndex + case 11: + if wireType != 2 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field SkipStoreKeys", 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.SkipStoreKeys = append(x.SkipStoreKeys, string(dAtA[iNdEx:postIndex])) + iNdEx = postIndex default: iNdEx = preIndex skippy, err := runtime.Skip(dAtA[iNdEx:]) @@ -2547,13 +2671,17 @@ type Module struct { // if it is specified. ExportGenesis []string `protobuf:"bytes,7,rep,name=export_genesis,json=exportGenesis,proto3" json:"export_genesis,omitempty"` // order_migrations defines the order in which module migrations are performed. - // If this is left empty, it uses the default migration order (alphabeticaly). + // If this is left empty, it uses the default migration order (alphabetically). OrderMigrations []string `protobuf:"bytes,8,rep,name=order_migrations,json=orderMigrations,proto3" json:"order_migrations,omitempty"` // GasConfig is the config object for gas limits. GasConfig *GasConfig `protobuf:"bytes,9,opt,name=gas_config,json=gasConfig,proto3" json:"gas_config,omitempty"` // override_store_keys is an optional list of overrides for the module store keys // to be used in keeper construction. OverrideStoreKeys []*StoreKeyConfig `protobuf:"bytes,10,rep,name=override_store_keys,json=overrideStoreKeys,proto3" json:"override_store_keys,omitempty"` + // skip_store_keys is an optional list of store keys to skip when constructing the + // module's keeper. This is useful when a module does not have a store key. + // NOTE: the provided environment variable will have a fake store service. + SkipStoreKeys []string `protobuf:"bytes,11,rep,name=skip_store_keys,json=skipStoreKeys,proto3" json:"skip_store_keys,omitempty"` } func (x *Module) Reset() { @@ -2646,6 +2774,13 @@ func (x *Module) GetOverrideStoreKeys() []*StoreKeyConfig { return nil } +func (x *Module) GetSkipStoreKeys() []string { + if x != nil { + return x.SkipStoreKeys + } + return nil +} + // GasConfig is the config object for gas limits. type GasConfig struct { state protoimpl.MessageState @@ -2753,7 +2888,7 @@ var file_cosmos_app_runtime_v2_module_proto_rawDesc = []byte{ 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x15, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x72, 0x75, 0x6e, 0x74, 0x69, 0x6d, 0x65, 0x2e, 0x76, 0x32, 0x1a, 0x20, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x61, 0x70, 0x70, 0x2f, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, - 0x2f, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xfa, 0x03, + 0x2f, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xa2, 0x04, 0x0a, 0x06, 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x12, 0x19, 0x0a, 0x08, 0x61, 0x70, 0x70, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x61, 0x70, 0x70, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x21, 0x0a, 0x0c, 0x70, 0x72, 0x65, 0x5f, 0x62, 0x6c, 0x6f, 0x63, 0x6b, @@ -2782,39 +2917,41 @@ var file_cosmos_app_runtime_v2_module_proto_rawDesc = []byte{ 0x73, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x72, 0x75, 0x6e, 0x74, 0x69, 0x6d, 0x65, 0x2e, 0x76, 0x32, 0x2e, 0x53, 0x74, 0x6f, 0x72, 0x65, 0x4b, 0x65, 0x79, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x11, 0x6f, 0x76, 0x65, 0x72, 0x72, 0x69, 0x64, 0x65, 0x53, 0x74, 0x6f, 0x72, 0x65, 0x4b, 0x65, - 0x79, 0x73, 0x3a, 0x36, 0xba, 0xc0, 0x96, 0xda, 0x01, 0x30, 0x0a, 0x17, 0x63, 0x6f, 0x73, 0x6d, - 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x72, 0x75, 0x6e, 0x74, 0x69, 0x6d, 0x65, - 0x2f, 0x76, 0x32, 0x12, 0x15, 0x0a, 0x13, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x61, 0x70, - 0x70, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x22, 0x98, 0x01, 0x0a, 0x09, 0x47, - 0x61, 0x73, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x31, 0x0a, 0x15, 0x76, 0x61, 0x6c, 0x69, - 0x64, 0x61, 0x74, 0x65, 0x5f, 0x74, 0x78, 0x5f, 0x67, 0x61, 0x73, 0x5f, 0x6c, 0x69, 0x6d, 0x69, - 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x12, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, - 0x65, 0x54, 0x78, 0x47, 0x61, 0x73, 0x4c, 0x69, 0x6d, 0x69, 0x74, 0x12, 0x26, 0x0a, 0x0f, 0x71, - 0x75, 0x65, 0x72, 0x79, 0x5f, 0x67, 0x61, 0x73, 0x5f, 0x6c, 0x69, 0x6d, 0x69, 0x74, 0x18, 0x02, - 0x20, 0x01, 0x28, 0x04, 0x52, 0x0d, 0x71, 0x75, 0x65, 0x72, 0x79, 0x47, 0x61, 0x73, 0x4c, 0x69, - 0x6d, 0x69, 0x74, 0x12, 0x30, 0x0a, 0x14, 0x73, 0x69, 0x6d, 0x75, 0x6c, 0x61, 0x74, 0x69, 0x6f, - 0x6e, 0x5f, 0x67, 0x61, 0x73, 0x5f, 0x6c, 0x69, 0x6d, 0x69, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, - 0x04, 0x52, 0x12, 0x73, 0x69, 0x6d, 0x75, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x47, 0x61, 0x73, - 0x4c, 0x69, 0x6d, 0x69, 0x74, 0x22, 0x53, 0x0a, 0x0e, 0x53, 0x74, 0x6f, 0x72, 0x65, 0x4b, 0x65, - 0x79, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x1f, 0x0a, 0x0b, 0x6d, 0x6f, 0x64, 0x75, 0x6c, - 0x65, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x6d, 0x6f, - 0x64, 0x75, 0x6c, 0x65, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x20, 0x0a, 0x0c, 0x6b, 0x76, 0x5f, 0x73, - 0x74, 0x6f, 0x72, 0x65, 0x5f, 0x6b, 0x65, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, - 0x6b, 0x76, 0x53, 0x74, 0x6f, 0x72, 0x65, 0x4b, 0x65, 0x79, 0x42, 0xd1, 0x01, 0x0a, 0x19, 0x63, - 0x6f, 0x6d, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x72, 0x75, - 0x6e, 0x74, 0x69, 0x6d, 0x65, 0x2e, 0x76, 0x32, 0x42, 0x0b, 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, - 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x30, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x73, - 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, - 0x2f, 0x61, 0x70, 0x70, 0x2f, 0x72, 0x75, 0x6e, 0x74, 0x69, 0x6d, 0x65, 0x2f, 0x76, 0x32, 0x3b, - 0x72, 0x75, 0x6e, 0x74, 0x69, 0x6d, 0x65, 0x76, 0x32, 0xa2, 0x02, 0x03, 0x43, 0x41, 0x52, 0xaa, - 0x02, 0x15, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x41, 0x70, 0x70, 0x2e, 0x52, 0x75, 0x6e, - 0x74, 0x69, 0x6d, 0x65, 0x2e, 0x56, 0x32, 0xca, 0x02, 0x15, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, - 0x5c, 0x41, 0x70, 0x70, 0x5c, 0x52, 0x75, 0x6e, 0x74, 0x69, 0x6d, 0x65, 0x5c, 0x56, 0x32, 0xe2, - 0x02, 0x21, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x5c, 0x41, 0x70, 0x70, 0x5c, 0x52, 0x75, 0x6e, - 0x74, 0x69, 0x6d, 0x65, 0x5c, 0x56, 0x32, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, - 0x61, 0x74, 0x61, 0xea, 0x02, 0x18, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x3a, 0x3a, 0x41, 0x70, - 0x70, 0x3a, 0x3a, 0x52, 0x75, 0x6e, 0x74, 0x69, 0x6d, 0x65, 0x3a, 0x3a, 0x56, 0x32, 0x62, 0x06, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x79, 0x73, 0x12, 0x26, 0x0a, 0x0f, 0x73, 0x6b, 0x69, 0x70, 0x5f, 0x73, 0x74, 0x6f, 0x72, 0x65, + 0x5f, 0x6b, 0x65, 0x79, 0x73, 0x18, 0x0b, 0x20, 0x03, 0x28, 0x09, 0x52, 0x0d, 0x73, 0x6b, 0x69, + 0x70, 0x53, 0x74, 0x6f, 0x72, 0x65, 0x4b, 0x65, 0x79, 0x73, 0x3a, 0x36, 0xba, 0xc0, 0x96, 0xda, + 0x01, 0x30, 0x0a, 0x17, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, + 0x2f, 0x72, 0x75, 0x6e, 0x74, 0x69, 0x6d, 0x65, 0x2f, 0x76, 0x32, 0x12, 0x15, 0x0a, 0x13, 0x63, + 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, + 0x61, 0x31, 0x22, 0x98, 0x01, 0x0a, 0x09, 0x47, 0x61, 0x73, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, + 0x12, 0x31, 0x0a, 0x15, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x5f, 0x74, 0x78, 0x5f, + 0x67, 0x61, 0x73, 0x5f, 0x6c, 0x69, 0x6d, 0x69, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, + 0x12, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x54, 0x78, 0x47, 0x61, 0x73, 0x4c, 0x69, + 0x6d, 0x69, 0x74, 0x12, 0x26, 0x0a, 0x0f, 0x71, 0x75, 0x65, 0x72, 0x79, 0x5f, 0x67, 0x61, 0x73, + 0x5f, 0x6c, 0x69, 0x6d, 0x69, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0d, 0x71, 0x75, + 0x65, 0x72, 0x79, 0x47, 0x61, 0x73, 0x4c, 0x69, 0x6d, 0x69, 0x74, 0x12, 0x30, 0x0a, 0x14, 0x73, + 0x69, 0x6d, 0x75, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x67, 0x61, 0x73, 0x5f, 0x6c, 0x69, + 0x6d, 0x69, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x04, 0x52, 0x12, 0x73, 0x69, 0x6d, 0x75, 0x6c, + 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x47, 0x61, 0x73, 0x4c, 0x69, 0x6d, 0x69, 0x74, 0x22, 0x53, 0x0a, + 0x0e, 0x53, 0x74, 0x6f, 0x72, 0x65, 0x4b, 0x65, 0x79, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, + 0x1f, 0x0a, 0x0b, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x4e, 0x61, 0x6d, 0x65, + 0x12, 0x20, 0x0a, 0x0c, 0x6b, 0x76, 0x5f, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x5f, 0x6b, 0x65, 0x79, + 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x6b, 0x76, 0x53, 0x74, 0x6f, 0x72, 0x65, 0x4b, + 0x65, 0x79, 0x42, 0xd1, 0x01, 0x0a, 0x19, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, + 0x73, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x72, 0x75, 0x6e, 0x74, 0x69, 0x6d, 0x65, 0x2e, 0x76, 0x32, + 0x42, 0x0b, 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, + 0x30, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x61, 0x70, + 0x69, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x61, 0x70, 0x70, 0x2f, 0x72, 0x75, 0x6e, + 0x74, 0x69, 0x6d, 0x65, 0x2f, 0x76, 0x32, 0x3b, 0x72, 0x75, 0x6e, 0x74, 0x69, 0x6d, 0x65, 0x76, + 0x32, 0xa2, 0x02, 0x03, 0x43, 0x41, 0x52, 0xaa, 0x02, 0x15, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, + 0x2e, 0x41, 0x70, 0x70, 0x2e, 0x52, 0x75, 0x6e, 0x74, 0x69, 0x6d, 0x65, 0x2e, 0x56, 0x32, 0xca, + 0x02, 0x15, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x5c, 0x41, 0x70, 0x70, 0x5c, 0x52, 0x75, 0x6e, + 0x74, 0x69, 0x6d, 0x65, 0x5c, 0x56, 0x32, 0xe2, 0x02, 0x21, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, + 0x5c, 0x41, 0x70, 0x70, 0x5c, 0x52, 0x75, 0x6e, 0x74, 0x69, 0x6d, 0x65, 0x5c, 0x56, 0x32, 0x5c, + 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x18, 0x43, 0x6f, + 0x73, 0x6d, 0x6f, 0x73, 0x3a, 0x3a, 0x41, 0x70, 0x70, 0x3a, 0x3a, 0x52, 0x75, 0x6e, 0x74, 0x69, + 0x6d, 0x65, 0x3a, 0x3a, 0x56, 0x32, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/api/go.mod b/api/go.mod index b94641857d4f..d888181d5a1e 100644 --- a/api/go.mod +++ b/api/go.mod @@ -2,8 +2,6 @@ module cosmossdk.io/api go 1.21 -toolchain go1.22.1 - require ( buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.34.1-20240312114316-c0d3497e35d6.1 github.com/cosmos/cosmos-proto v1.0.0-beta.5 diff --git a/go.work.example b/go.work.example index cb34d87ef59d..614d1e7d0629 100644 --- a/go.work.example +++ b/go.work.example @@ -1,7 +1,5 @@ go 1.22.2 -toolchain go1.22.2 - use ( . ./api diff --git a/proto/cosmos/app/runtime/v1alpha1/module.proto b/proto/cosmos/app/runtime/v1alpha1/module.proto index 6ada4d8ca136..516156dcb7d1 100644 --- a/proto/cosmos/app/runtime/v1alpha1/module.proto +++ b/proto/cosmos/app/runtime/v1alpha1/module.proto @@ -38,6 +38,11 @@ message Module { // to be used in keeper construction. repeated StoreKeyConfig override_store_keys = 6; + // skip_store_keys is an optional list of store keys to skip when constructing the + // module's keeper. This is useful when a module does not have a store key. + // NOTE: the provided environment variable will have a fake store service. + repeated string skip_store_keys = 11; + // order_migrations defines the order in which module migrations are performed. // If this is left empty, it uses the default migration order. // https://pkg.go.dev/github.com/cosmos/cosmos-sdk@v0.47.0-alpha2/types/module#DefaultMigrationsOrder diff --git a/proto/cosmos/app/runtime/v2/module.proto b/proto/cosmos/app/runtime/v2/module.proto index 4184f50565d9..dbc087e3b5cc 100644 --- a/proto/cosmos/app/runtime/v2/module.proto +++ b/proto/cosmos/app/runtime/v2/module.proto @@ -53,6 +53,11 @@ message Module { // override_store_keys is an optional list of overrides for the module store keys // to be used in keeper construction. repeated StoreKeyConfig override_store_keys = 10; + + // skip_store_keys is an optional list of store keys to skip when constructing the + // module's keeper. This is useful when a module does not have a store key. + // NOTE: the provided environment variable will have a fake store service. + repeated string skip_store_keys = 11; } // GasConfig is the config object for gas limits. diff --git a/runtime/module.go b/runtime/module.go index c7f369dbc975..18145b60f051 100644 --- a/runtime/module.go +++ b/runtime/module.go @@ -3,6 +3,7 @@ package runtime import ( "fmt" "os" + "slices" "github.com/cosmos/gogoproto/proto" "google.golang.org/protobuf/reflect/protodesc" @@ -192,6 +193,10 @@ func ProvideKVStoreKey( key depinject.ModuleKey, app *AppBuilder, ) *storetypes.KVStoreKey { + if slices.Contains(config.SkipStoreKeys, key.Name()) { + return nil + } + override := storeKeyOverride(config, key.Name()) var storeKeyName string @@ -206,13 +211,29 @@ func ProvideKVStoreKey( return storeKey } -func ProvideTransientStoreKey(key depinject.ModuleKey, app *AppBuilder) *storetypes.TransientStoreKey { +func ProvideTransientStoreKey( + config *runtimev1alpha1.Module, + key depinject.ModuleKey, + app *AppBuilder, +) *storetypes.TransientStoreKey { + if slices.Contains(config.SkipStoreKeys, key.Name()) { + return nil + } + storeKey := storetypes.NewTransientStoreKey(fmt.Sprintf("transient:%s", key.Name())) registerStoreKey(app, storeKey) return storeKey } -func ProvideMemoryStoreKey(key depinject.ModuleKey, app *AppBuilder) *storetypes.MemoryStoreKey { +func ProvideMemoryStoreKey( + config *runtimev1alpha1.Module, + key depinject.ModuleKey, + app *AppBuilder, +) *storetypes.MemoryStoreKey { + if slices.Contains(config.SkipStoreKeys, key.Name()) { + return nil + } + storeKey := storetypes.NewMemoryStoreKey(fmt.Sprintf("memory:%s", key.Name())) registerStoreKey(app, storeKey) return storeKey @@ -234,23 +255,39 @@ func ProvideEnvironment( msgServiceRouter *baseapp.MsgServiceRouter, queryServiceRouter *baseapp.GRPCQueryRouter, ) (store.KVStoreService, store.MemoryStoreService, appmodule.Environment) { - storeKey := ProvideKVStoreKey(config, key, app) - kvService := kvStoreService{key: storeKey} + var ( + kvService store.KVStoreService = failingStoreService{} + memKvService store.MemoryStoreService = failingStoreService{} + ) - memStoreKey := ProvideMemoryStoreKey(key, app) - memStoreService := memStoreService{key: memStoreKey} + // skips modules that have no store + if !slices.Contains(config.SkipStoreKeys, key.Name()) { + storeKey := ProvideKVStoreKey(config, key, app) + kvService = kvStoreService{key: storeKey} + + memStoreKey := ProvideMemoryStoreKey(config, key, app) + memKvService = memStoreService{key: memStoreKey} + } - return kvService, memStoreService, NewEnvironment( + return kvService, memKvService, NewEnvironment( kvService, logger.With(log.ModuleKey, fmt.Sprintf("x/%s", key.Name())), EnvWithMsgRouterService(msgServiceRouter), EnvWithQueryRouterService(queryServiceRouter), - EnvWithMemStoreService(memStoreService), + EnvWithMemStoreService(memKvService), ) } -func ProvideTransientStoreService(key depinject.ModuleKey, app *AppBuilder) store.TransientStoreService { - storeKey := ProvideTransientStoreKey(key, app) +func ProvideTransientStoreService( + config *runtimev1alpha1.Module, + key depinject.ModuleKey, + app *AppBuilder, +) store.TransientStoreService { + storeKey := ProvideTransientStoreKey(config, key, app) + if storeKey == nil { + return failingStoreService{} + } + return transientStoreService{key: storeKey} } diff --git a/runtime/store.go b/runtime/store.go index 5a5f21647bcf..817d9719a64a 100644 --- a/runtime/store.go +++ b/runtime/store.go @@ -48,6 +48,20 @@ func (t transientStoreService) OpenTransientStore(ctx context.Context) store.KVS return newKVStore(sdk.UnwrapSDKContext(ctx).KVStore(t.key)) } +type failingStoreService struct{} + +func (failingStoreService) OpenKVStore(ctx context.Context) store.KVStore { + panic("kv store service not available for this module: verify runtime `skip_store_keys` app config if not expected") +} + +func (failingStoreService) OpenMemoryStore(ctx context.Context) store.KVStore { + panic("memory kv store service not available for this module: verify runtime `skip_store_keys` app config if not expected") +} + +func (failingStoreService) OpenTransientStore(ctx context.Context) store.KVStore { + panic("transient kv store service not available for this module: verify runtime `skip_store_keys` app config if not expected") +} + // CoreKVStore is a wrapper of Core/Store kvstore interface // Remove after https://github.com/cosmos/cosmos-sdk/issues/14714 is closed type coreKVStore struct { diff --git a/runtime/v2/module.go b/runtime/v2/module.go index 15d0c290aea5..2fd62c304f89 100644 --- a/runtime/v2/module.go +++ b/runtime/v2/module.go @@ -3,6 +3,7 @@ package runtime import ( "fmt" "os" + "slices" "github.com/cosmos/gogoproto/proto" "google.golang.org/grpc" @@ -185,19 +186,28 @@ func ProvideEnvironment(logger log.Logger, config *runtimev2.Module, key depinje store.KVStoreService, store.MemoryStoreService, ) { - var kvStoreKey string - storeKeyOverride := storeKeyOverride(config, key.Name()) - if storeKeyOverride != nil { - kvStoreKey = storeKeyOverride.KvStoreKey - } else { - kvStoreKey = key.Name() - } - registerStoreKey(appBuilder, kvStoreKey) - kvService := stf.NewKVStoreService([]byte(kvStoreKey)) + var ( + kvService store.KVStoreService = failingStoreService{} + memKvService store.MemoryStoreService = failingStoreService{} + ) + + // skips modules that have no store + if !slices.Contains(config.SkipStoreKeys, key.Name()) { + var kvStoreKey string + storeKeyOverride := storeKeyOverride(config, key.Name()) + if storeKeyOverride != nil { + kvStoreKey = storeKeyOverride.KvStoreKey + } else { + kvStoreKey = key.Name() + } + + registerStoreKey(appBuilder, kvStoreKey) + kvService = stf.NewKVStoreService([]byte(kvStoreKey)) - memStoreKey := fmt.Sprintf("memory:%s", key.Name()) - registerStoreKey(appBuilder, memStoreKey) - memService := stf.NewMemoryStoreService([]byte(memStoreKey)) + memStoreKey := fmt.Sprintf("memory:%s", key.Name()) + registerStoreKey(appBuilder, memStoreKey) + memKvService = stf.NewMemoryStoreService([]byte(memStoreKey)) + } env := appmodulev2.Environment{ Logger: logger, @@ -209,10 +219,10 @@ func ProvideEnvironment(logger log.Logger, config *runtimev2.Module, key depinje MsgRouterService: stf.NewMsgRouterService(appBuilder.app.msgRouterBuilder), TransactionService: services.NewContextAwareTransactionService(), KVStoreService: kvService, - MemStoreService: memService, + MemStoreService: memKvService, } - return env, kvService, memService + return env, kvService, memKvService } func registerStoreKey(wrapper *AppBuilder, key string) { diff --git a/runtime/v2/stub.go b/runtime/v2/stub.go new file mode 100644 index 000000000000..48bedaf17c97 --- /dev/null +++ b/runtime/v2/stub.go @@ -0,0 +1,21 @@ +package runtime + +import ( + "context" + + "cosmossdk.io/core/store" +) + +type failingStoreService struct{} + +func (failingStoreService) OpenKVStore(ctx context.Context) store.KVStore { + panic("kv store service not available for this module: verify runtime `skip_store_keys` app config if not expected") +} + +func (failingStoreService) OpenMemoryStore(ctx context.Context) store.KVStore { + panic("memory kv store service not available for this module: verify runtime `skip_store_keys` app config if not expected") +} + +func (failingStoreService) OpenTransientStore(ctx context.Context) store.KVStore { + panic("transient kv store service not available for this module: verify runtime `skip_store_keys` app config if not expected") +} diff --git a/simapp/CHANGELOG.md b/simapp/CHANGELOG.md new file mode 100644 index 000000000000..4d0d22dad753 --- /dev/null +++ b/simapp/CHANGELOG.md @@ -0,0 +1,50 @@ + + +# Changelog + +`SimApp` is an application built using the Cosmos SDK for testing and educational purposes. +It won't be tagged or intented to be imported in an application. +This changelog is aimed to help developers understand the wiring changes between SDK versions. +It is an exautive list of changes that completes the SimApp section in the [UPGRADING.md](https://github.com/cosmos/cosmos-sdk/blob/main/UPGRADING.md#simapp) + +## v0.50 to v0.51 + +Always refer to the [UPGRADING.md](https://github.com/cosmos/cosmos-sdk/blob/main/UPGRADING.md) to understand the changes. + +* [#20409](https://github.com/cosmos/cosmos-sdk/pull/20409) Add `tx` as `SkipStoreKeys` in `app_config.go`. + + + +## v0.47 to v0.50 + +No changelog is provided for this migration. Please refer to the [UPGRADING.md](https://github.com/cosmos/cosmos-sdk/blob/main/UPGRADING.md#v050x) + +## v0.46 to v0.47 + +No changelog is provided for this migration. Please refer to the [UPGRADING.md](https://github.com/cosmos/cosmos-sdk/blob/main/UPGRADING.md#v047x) + +## v0.45 to v0.46 + +No changelog is provided for this migration. Please refer to the [UPGRADING.md](https://github.com/cosmos/cosmos-sdk/blob/main/UPGRADING.md#v046x) + diff --git a/simapp/app_config.go b/simapp/app_config.go index b899fbd7f2a6..f7f924825b05 100644 --- a/simapp/app_config.go +++ b/simapp/app_config.go @@ -170,6 +170,11 @@ var ( // ExportGenesis: []string{}, // Uncomment if you want to set a custom migration order here. // OrderMigrations: []string{}, + // SkipStoreKeys is an optional list of store keys to skip when constructing the + // module's keeper. This is useful when a module does not have a store key. + SkipStoreKeys: []string{ + "tx", + }, }), }, {