diff --git a/CHANGELOG.md b/CHANGELOG.md index 8f691b0c9f..2025ce8365 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -96,6 +96,7 @@ Every module contains its own CHANGELOG.md. Please refer to the module you are i ### API Breaking Changes +* (x/consensus) [#19488](https://github.com/cosmos/cosmos-sdk/pull/19488) Consensus module creation takes `appmodule.Environment` instead of individual services. * (server) [#18303](https://github.com/cosmos/cosmos-sdk/pull/18303) `x/genutil` now handles the application export. `server.AddCommands` does not take an `AppExporter` but instead `genutilcli.Commands` does. * (x/gov/testutil) [#17986](https://github.com/cosmos/cosmos-sdk/pull/18036) `MsgDeposit` has been removed because of AutoCLI migration. * (x/staking/testutil) [#17986](https://github.com/cosmos/cosmos-sdk/pull/17986) `MsgRedelegateExec`, `MsgUnbondExec` has been removed because of AutoCLI migration. diff --git a/simapp/app.go b/simapp/app.go index 7f524b0c43..f67bd9bf01 100644 --- a/simapp/app.go +++ b/simapp/app.go @@ -280,7 +280,7 @@ func NewSimApp( } // set the BaseApp's parameter store - app.ConsensusParamsKeeper = consensusparamkeeper.NewKeeper(appCodec, runtime.NewKVStoreService(keys[consensusparamtypes.StoreKey]), authtypes.NewModuleAddress(govtypes.ModuleName).String(), runtime.EventService{}) + app.ConsensusParamsKeeper = consensusparamkeeper.NewKeeper(appCodec, runtime.NewEnvironment(runtime.NewKVStoreService(keys[consensusparamtypes.StoreKey]), logger), authtypes.NewModuleAddress(govtypes.ModuleName).String()) bApp.SetParamStore(app.ConsensusParamsKeeper.ParamsStore) addressCodec := authcodec.NewBech32Codec(sdk.Bech32MainPrefix) diff --git a/testutil/integration/router.go b/testutil/integration/router.go index cbb5798232..fcf147a288 100644 --- a/testutil/integration/router.go +++ b/testutil/integration/router.go @@ -82,7 +82,7 @@ func NewIntegrationApp( if keys[consensusparamtypes.StoreKey] != nil { // set baseApp param store - consensusParamsKeeper := consensusparamkeeper.NewKeeper(appCodec, runtime.NewKVStoreService(keys[consensusparamtypes.StoreKey]), authtypes.NewModuleAddress("gov").String(), runtime.EventService{}) + consensusParamsKeeper := consensusparamkeeper.NewKeeper(appCodec, runtime.NewEnvironment(runtime.NewKVStoreService(keys[consensusparamtypes.StoreKey]), log.NewNopLogger()), authtypes.NewModuleAddress("gov").String()) bApp.SetParamStore(consensusParamsKeeper.ParamsStore) if err := bApp.LoadLatestVersion(); err != nil { diff --git a/x/consensus/depinject.go b/x/consensus/depinject.go index 9f613acf36..695c609e17 100644 --- a/x/consensus/depinject.go +++ b/x/consensus/depinject.go @@ -3,8 +3,6 @@ package consensus import ( modulev1 "cosmossdk.io/api/cosmos/consensus/module/v1" "cosmossdk.io/core/appmodule" - "cosmossdk.io/core/event" - storetypes "cosmossdk.io/core/store" "cosmossdk.io/depinject" "cosmossdk.io/depinject/appconfig" authtypes "cosmossdk.io/x/auth/types" @@ -30,10 +28,9 @@ func init() { type ModuleInputs struct { depinject.In - Config *modulev1.Module - Cdc codec.Codec - StoreService storetypes.KVStoreService - EventManager event.Service + Config *modulev1.Module + Cdc codec.Codec + Environment appmodule.Environment } type ModuleOutputs struct { @@ -51,7 +48,7 @@ func ProvideModule(in ModuleInputs) ModuleOutputs { authority = authtypes.NewModuleAddressOrBech32Address(in.Config.Authority) } - k := keeper.NewKeeper(in.Cdc, in.StoreService, authority.String(), in.EventManager) + k := keeper.NewKeeper(in.Cdc, in.Environment, authority.String()) m := NewAppModule(in.Cdc, k) baseappOpt := func(app *baseapp.BaseApp) { app.SetParamStore(k.ParamsStore) diff --git a/x/consensus/keeper/keeper.go b/x/consensus/keeper/keeper.go index a0ccf562de..48112da959 100644 --- a/x/consensus/keeper/keeper.go +++ b/x/consensus/keeper/keeper.go @@ -10,8 +10,8 @@ import ( "google.golang.org/grpc/status" "cosmossdk.io/collections" + "cosmossdk.io/core/appmodule" "cosmossdk.io/core/event" - storetypes "cosmossdk.io/core/store" "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/x/consensus/exported" @@ -21,8 +21,7 @@ import ( var StoreKey = "Consensus" type Keeper struct { - storeService storetypes.KVStoreService - event event.Service + environment appmodule.Environment authority string ParamsStore collections.Item[cmtproto.ConsensusParams] @@ -30,13 +29,12 @@ type Keeper struct { var _ exported.ConsensusParamSetter = Keeper{}.ParamsStore -func NewKeeper(cdc codec.BinaryCodec, storeService storetypes.KVStoreService, authority string, em event.Service) Keeper { - sb := collections.NewSchemaBuilder(storeService) +func NewKeeper(cdc codec.BinaryCodec, env appmodule.Environment, authority string) Keeper { + sb := collections.NewSchemaBuilder(env.KVStoreService) return Keeper{ - storeService: storeService, - authority: authority, - event: em, - ParamsStore: collections.NewItem(sb, collections.NewPrefix("Consensus"), "params", codec.CollValue[cmtproto.ConsensusParams](cdc)), + environment: env, + authority: authority, + ParamsStore: collections.NewItem(sb, collections.NewPrefix("Consensus"), "params", codec.CollValue[cmtproto.ConsensusParams](cdc)), } } @@ -79,7 +77,7 @@ func (k Keeper) UpdateParams(ctx context.Context, msg *types.MsgUpdateParams) (* return nil, err } - if err := k.event.EventManager(ctx).EmitKV( + if err := k.environment.EventService.EventManager(ctx).EmitKV( "update_consensus_params", event.NewAttribute("authority", msg.Authority), event.NewAttribute("parameters", consensusParams.String())); err != nil { diff --git a/x/consensus/keeper/keeper_test.go b/x/consensus/keeper/keeper_test.go index 3c3f9d97e4..b49c634f75 100644 --- a/x/consensus/keeper/keeper_test.go +++ b/x/consensus/keeper/keeper_test.go @@ -7,6 +7,7 @@ import ( cmttypes "github.com/cometbft/cometbft/types" "github.com/stretchr/testify/suite" + "cosmossdk.io/log" storetypes "cosmossdk.io/store/types" authtypes "cosmossdk.io/x/auth/types" @@ -32,9 +33,9 @@ func (s *KeeperTestSuite) SetupTest() { testCtx := testutil.DefaultContextWithDB(s.T(), key, storetypes.NewTransientStoreKey("transient_test")) ctx := testCtx.Ctx encCfg := moduletestutil.MakeTestEncodingConfig() - storeService := runtime.NewKVStoreService(key) + env := runtime.NewEnvironment(runtime.NewKVStoreService(key), log.NewNopLogger()) - keeper := consensusparamkeeper.NewKeeper(encCfg.Codec, storeService, authtypes.NewModuleAddress("gov").String(), runtime.EventService{}) + keeper := consensusparamkeeper.NewKeeper(encCfg.Codec, env, authtypes.NewModuleAddress("gov").String()) s.ctx = ctx s.consensusParamsKeeper = &keeper