From c8836248d16e6a4e3f0ba012d5a7f67796c8a640 Mon Sep 17 00:00:00 2001 From: Marko Date: Mon, 19 Feb 2024 22:09:11 +0100 Subject: [PATCH] refactor(auth): migrate to use env (#19476) --- simapp/app.go | 2 +- .../integration/bank/keeper/deterministic_test.go | 2 +- .../distribution/keeper/msg_server_test.go | 2 +- .../integration/evidence/keeper/infraction_test.go | 2 +- tests/integration/example/example_test.go | 4 ++-- tests/integration/gov/keeper/keeper_test.go | 2 +- tests/integration/slashing/keeper/keeper_test.go | 2 +- tests/integration/staking/keeper/common_test.go | 2 +- .../staking/keeper/deterministic_test.go | 2 +- x/auth/CHANGELOG.md | 1 + x/auth/ante/testutil_test.go | 3 ++- x/auth/depinject.go | 9 ++++----- x/auth/keeper/deterministic_test.go | 14 ++++++++------ x/auth/keeper/keeper.go | 12 ++++++------ x/auth/keeper/keeper_test.go | 4 +++- x/auth/keeper/migrations.go | 4 ++-- x/auth/keeper/msg_server.go | 5 +---- x/auth/vesting/fuzz_test.go | 6 +++--- x/auth/vesting/msg_server.go | 3 +-- x/auth/vesting/msg_server_test.go | 6 ++++-- x/auth/vesting/types/vesting_account_test.go | 5 +++-- x/distribution/migrations/v4/migrate_funds_test.go | 2 +- x/group/migrations/v2/migrate_test.go | 3 ++- 23 files changed, 51 insertions(+), 46 deletions(-) diff --git a/simapp/app.go b/simapp/app.go index 9931c37a22..f1af97b62d 100644 --- a/simapp/app.go +++ b/simapp/app.go @@ -305,7 +305,7 @@ func NewSimApp( } app.AccountsKeeper = accountsKeeper - app.AuthKeeper = authkeeper.NewAccountKeeper(appCodec, runtime.NewKVStoreService(keys[authtypes.StoreKey]), authtypes.ProtoBaseAccount, maccPerms, addressCodec, sdk.Bech32MainPrefix, authtypes.NewModuleAddress(govtypes.ModuleName).String()) + app.AuthKeeper = authkeeper.NewAccountKeeper(runtime.NewEnvironment(runtime.NewKVStoreService(keys[authtypes.StoreKey]), logger), appCodec, authtypes.ProtoBaseAccount, maccPerms, addressCodec, sdk.Bech32MainPrefix, authtypes.NewModuleAddress(govtypes.ModuleName).String()) app.BankKeeper = bankkeeper.NewBaseKeeper( appCodec, diff --git a/tests/integration/bank/keeper/deterministic_test.go b/tests/integration/bank/keeper/deterministic_test.go index ae8679236c..6c02a38e0c 100644 --- a/tests/integration/bank/keeper/deterministic_test.go +++ b/tests/integration/bank/keeper/deterministic_test.go @@ -77,8 +77,8 @@ func initDeterministicFixture(t *testing.T) *deterministicFixture { } accountKeeper := authkeeper.NewAccountKeeper( + runtime.NewEnvironment(runtime.NewKVStoreService(keys[authtypes.StoreKey]), log.NewNopLogger()), cdc, - runtime.NewKVStoreService(keys[authtypes.StoreKey]), authtypes.ProtoBaseAccount, maccPerms, addresscodec.NewBech32Codec(sdk.Bech32MainPrefix), diff --git a/tests/integration/distribution/keeper/msg_server_test.go b/tests/integration/distribution/keeper/msg_server_test.go index c20fe78646..2e5f64deb1 100644 --- a/tests/integration/distribution/keeper/msg_server_test.go +++ b/tests/integration/distribution/keeper/msg_server_test.go @@ -84,8 +84,8 @@ func initFixture(t *testing.T) *fixture { } accountKeeper := authkeeper.NewAccountKeeper( + runtime.NewEnvironment(runtime.NewKVStoreService(keys[authtypes.StoreKey]), log.NewNopLogger()), cdc, - runtime.NewKVStoreService(keys[authtypes.StoreKey]), authtypes.ProtoBaseAccount, maccPerms, addresscodec.NewBech32Codec(sdk.Bech32MainPrefix), diff --git a/tests/integration/evidence/keeper/infraction_test.go b/tests/integration/evidence/keeper/infraction_test.go index dea665e70a..f56f4d15ca 100644 --- a/tests/integration/evidence/keeper/infraction_test.go +++ b/tests/integration/evidence/keeper/infraction_test.go @@ -104,8 +104,8 @@ func initFixture(tb testing.TB) *fixture { } accountKeeper := authkeeper.NewAccountKeeper( + runtime.NewEnvironment(runtime.NewKVStoreService(keys[authtypes.StoreKey]), log.NewNopLogger()), cdc, - runtime.NewKVStoreService(keys[authtypes.StoreKey]), authtypes.ProtoBaseAccount, maccPerms, addresscodec.NewBech32Codec(sdk.Bech32MainPrefix), diff --git a/tests/integration/example/example_test.go b/tests/integration/example/example_test.go index 1db39ca237..8d4fa86aba 100644 --- a/tests/integration/example/example_test.go +++ b/tests/integration/example/example_test.go @@ -40,8 +40,8 @@ func Example() { newCtx := sdk.NewContext(cms, true, logger) accountKeeper := authkeeper.NewAccountKeeper( + runtime.NewEnvironment(runtime.NewKVStoreService(keys[authtypes.StoreKey]), log.NewNopLogger()), encodingCfg.Codec, - runtime.NewKVStoreService(keys[authtypes.StoreKey]), authtypes.ProtoBaseAccount, map[string][]string{minttypes.ModuleName: {authtypes.Minter}}, addresscodec.NewBech32Codec("cosmos"), @@ -129,8 +129,8 @@ func Example_oneModule() { newCtx := sdk.NewContext(cms, true, logger) accountKeeper := authkeeper.NewAccountKeeper( + runtime.NewEnvironment(runtime.NewKVStoreService(keys[authtypes.StoreKey]), log.NewNopLogger()), encodingCfg.Codec, - runtime.NewKVStoreService(keys[authtypes.StoreKey]), authtypes.ProtoBaseAccount, map[string][]string{minttypes.ModuleName: {authtypes.Minter}}, addresscodec.NewBech32Codec("cosmos"), diff --git a/tests/integration/gov/keeper/keeper_test.go b/tests/integration/gov/keeper/keeper_test.go index 002fa2e270..b6e8117fc4 100644 --- a/tests/integration/gov/keeper/keeper_test.go +++ b/tests/integration/gov/keeper/keeper_test.go @@ -71,8 +71,8 @@ func initFixture(tb testing.TB) *fixture { } accountKeeper := authkeeper.NewAccountKeeper( + runtime.NewEnvironment(runtime.NewKVStoreService(keys[authtypes.StoreKey]), log.NewNopLogger()), cdc, - runtime.NewKVStoreService(keys[authtypes.StoreKey]), authtypes.ProtoBaseAccount, maccPerms, addresscodec.NewBech32Codec(sdk.Bech32MainPrefix), diff --git a/tests/integration/slashing/keeper/keeper_test.go b/tests/integration/slashing/keeper/keeper_test.go index f1e6fbed7e..bf8b63833c 100644 --- a/tests/integration/slashing/keeper/keeper_test.go +++ b/tests/integration/slashing/keeper/keeper_test.go @@ -72,8 +72,8 @@ func initFixture(tb testing.TB) *fixture { } accountKeeper := authkeeper.NewAccountKeeper( + runtime.NewEnvironment(runtime.NewKVStoreService(keys[authtypes.StoreKey]), log.NewNopLogger()), cdc, - runtime.NewKVStoreService(keys[authtypes.StoreKey]), authtypes.ProtoBaseAccount, maccPerms, addresscodec.NewBech32Codec(sdk.Bech32MainPrefix), diff --git a/tests/integration/staking/keeper/common_test.go b/tests/integration/staking/keeper/common_test.go index e65f5d533c..1f0e7f146e 100644 --- a/tests/integration/staking/keeper/common_test.go +++ b/tests/integration/staking/keeper/common_test.go @@ -121,8 +121,8 @@ func initFixture(tb testing.TB) *fixture { } accountKeeper := authkeeper.NewAccountKeeper( + runtime.NewEnvironment(runtime.NewKVStoreService(keys[authtypes.StoreKey]), log.NewNopLogger()), cdc, - runtime.NewKVStoreService(keys[authtypes.StoreKey]), authtypes.ProtoBaseAccount, maccPerms, addresscodec.NewBech32Codec(sdk.Bech32MainPrefix), diff --git a/tests/integration/staking/keeper/deterministic_test.go b/tests/integration/staking/keeper/deterministic_test.go index 7cee04d5cd..e47f8cf168 100644 --- a/tests/integration/staking/keeper/deterministic_test.go +++ b/tests/integration/staking/keeper/deterministic_test.go @@ -85,8 +85,8 @@ func initDeterministicFixture(t *testing.T) *deterministicFixture { } accountKeeper := authkeeper.NewAccountKeeper( + runtime.NewEnvironment(runtime.NewKVStoreService(keys[authtypes.StoreKey]), log.NewNopLogger()), cdc, - runtime.NewKVStoreService(keys[authtypes.StoreKey]), authtypes.ProtoBaseAccount, maccPerms, addresscodec.NewBech32Codec(sdk.Bech32MainPrefix), diff --git a/x/auth/CHANGELOG.md b/x/auth/CHANGELOG.md index aa4aa5d13c..e7a346dd6b 100644 --- a/x/auth/CHANGELOG.md +++ b/x/auth/CHANGELOG.md @@ -46,6 +46,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ * [#17985](https://github.com/cosmos/cosmos-sdk/pull/17985) Remove `StdTxConfig` * [#19161](https://github.com/cosmos/cosmos-sdk/pull/19161) Remove `simulate` from `SetGasMeter` * [#19363](https://github.com/cosmos/cosmos-sdk/pull/19363) Remove `IterateAccounts` and `GetAllAccounts` methods from the AccountKeeper interface and Keeper. +* [#19290](https://github.com/cosmos/cosmos-sdk/issues/19290) Pass `appmodule.Environment` to NewKeeper instead of passing individual services. ### Consensus Breaking Changes diff --git a/x/auth/ante/testutil_test.go b/x/auth/ante/testutil_test.go index f91434007c..d412d31282 100644 --- a/x/auth/ante/testutil_test.go +++ b/x/auth/ante/testutil_test.go @@ -11,6 +11,7 @@ import ( // ref: https://github.com/cosmos/cosmos-sdk/issues/14647 _ "cosmossdk.io/api/cosmos/bank/v1beta1" _ "cosmossdk.io/api/cosmos/crypto/secp256k1" + "cosmossdk.io/log" storetypes "cosmossdk.io/store/types" "cosmossdk.io/x/auth" "cosmossdk.io/x/auth/ante" @@ -78,7 +79,7 @@ func SetupTestSuite(t *testing.T, isCheckTx bool) *AnteTestSuite { } suite.accountKeeper = keeper.NewAccountKeeper( - suite.encCfg.Codec, runtime.NewKVStoreService(key), types.ProtoBaseAccount, maccPerms, authcodec.NewBech32Codec("cosmos"), + runtime.NewEnvironment(runtime.NewKVStoreService(key), log.NewNopLogger()), suite.encCfg.Codec, types.ProtoBaseAccount, maccPerms, authcodec.NewBech32Codec("cosmos"), sdk.Bech32MainPrefix, types.NewModuleAddress("gov").String(), ) suite.accountKeeper.GetModuleAccount(suite.ctx, types.FeeCollectorName) diff --git a/x/auth/depinject.go b/x/auth/depinject.go index dcd624f99d..67d75e7c90 100644 --- a/x/auth/depinject.go +++ b/x/auth/depinject.go @@ -4,7 +4,6 @@ import ( modulev1 "cosmossdk.io/api/cosmos/auth/module/v1" "cosmossdk.io/core/address" "cosmossdk.io/core/appmodule" - "cosmossdk.io/core/store" "cosmossdk.io/depinject" "cosmossdk.io/depinject/appconfig" "cosmossdk.io/x/auth/keeper" @@ -29,9 +28,9 @@ func init() { type ModuleInputs struct { depinject.In - Config *modulev1.Module - StoreService store.KVStoreService - Cdc codec.Codec + Config *modulev1.Module + Environment appmodule.Environment + Cdc codec.Codec AddressCodec address.Codec RandomGenesisAccountsFn types.RandomGenesisAccountsFn `optional:"true"` @@ -70,7 +69,7 @@ func ProvideModule(in ModuleInputs) ModuleOutputs { panic(err) } - k := keeper.NewAccountKeeper(in.Cdc, in.StoreService, in.AccountI, maccPerms, in.AddressCodec, in.Config.Bech32Prefix, auth) + k := keeper.NewAccountKeeper(in.Environment, in.Cdc, in.AccountI, maccPerms, in.AddressCodec, in.Config.Bech32Prefix, auth) m := NewAppModule(in.Cdc, k, in.RandomGenesisAccountsFn) return ModuleOutputs{AccountKeeper: k, Module: m} diff --git a/x/auth/keeper/deterministic_test.go b/x/auth/keeper/deterministic_test.go index cfa954aae9..97074cd677 100644 --- a/x/auth/keeper/deterministic_test.go +++ b/x/auth/keeper/deterministic_test.go @@ -9,8 +9,9 @@ import ( "github.com/stretchr/testify/suite" "pgregory.net/rapid" + "cosmossdk.io/core/appmodule" "cosmossdk.io/core/header" - corestore "cosmossdk.io/core/store" + "cosmossdk.io/log" storetypes "cosmossdk.io/store/types" "cosmossdk.io/x/auth" authcodec "cosmossdk.io/x/auth/codec" @@ -32,7 +33,7 @@ type DeterministicTestSuite struct { accountNumberLanes uint64 key *storetypes.KVStoreKey - storeService corestore.KVStoreService + environment appmodule.Environment ctx sdk.Context queryClient types.QueryClient accountKeeper keeper.AccountKeeper @@ -56,6 +57,7 @@ func (suite *DeterministicTestSuite) SetupTest() { suite.Require() key := storetypes.NewKVStoreKey(types.StoreKey) storeService := runtime.NewKVStoreService(key) + env := runtime.NewEnvironment(storeService, log.NewNopLogger()) testCtx := testutil.DefaultContextWithDB(suite.T(), key, storetypes.NewTransientStoreKey("transient_test")) suite.ctx = testCtx.Ctx.WithHeaderInfo(header.Info{}) @@ -69,8 +71,8 @@ func (suite *DeterministicTestSuite) SetupTest() { } suite.accountKeeper = keeper.NewAccountKeeper( + env, suite.encCfg.Codec, - storeService, types.ProtoBaseAccount, maccPerms, authcodec.NewBech32Codec("cosmos"), @@ -83,7 +85,7 @@ func (suite *DeterministicTestSuite) SetupTest() { suite.queryClient = types.NewQueryClient(queryHelper) suite.key = key - suite.storeService = storeService + suite.environment = env suite.maccPerms = maccPerms suite.accountNumberLanes = 1 } @@ -289,8 +291,8 @@ func (suite *DeterministicTestSuite) TestGRPCQueryModuleAccounts() { } ak := keeper.NewAccountKeeper( + suite.environment, suite.encCfg.Codec, - suite.storeService, types.ProtoBaseAccount, maccPerms, authcodec.NewBech32Codec("cosmos"), @@ -336,8 +338,8 @@ func (suite *DeterministicTestSuite) TestGRPCQueryModuleAccountByName() { maccPerms[mName] = mPerms ak := keeper.NewAccountKeeper( + suite.environment, suite.encCfg.Codec, - suite.storeService, types.ProtoBaseAccount, maccPerms, authcodec.NewBech32Codec("cosmos"), diff --git a/x/auth/keeper/keeper.go b/x/auth/keeper/keeper.go index 63e7e0685e..6196236df2 100644 --- a/x/auth/keeper/keeper.go +++ b/x/auth/keeper/keeper.go @@ -8,7 +8,7 @@ import ( "cosmossdk.io/collections" "cosmossdk.io/collections/indexes" "cosmossdk.io/core/address" - "cosmossdk.io/core/store" + "cosmossdk.io/core/appmodule" errorsmod "cosmossdk.io/errors" "cosmossdk.io/log" "cosmossdk.io/x/auth/types" @@ -82,7 +82,7 @@ func (a AccountsIndexes) IndexesList() []collections.Index[sdk.AccAddress, sdk.A type AccountKeeper struct { addressCodec address.Codec - storeService store.KVStoreService + Environment appmodule.Environment cdc codec.BinaryCodec permAddrs map[string]types.PermissionsForAddress bech32Prefix string @@ -111,7 +111,7 @@ var _ AccountKeeperI = &AccountKeeper{} // and don't have to fit into any predefined structure. This auth module does not use account permissions internally, though other modules // may use auth.Keeper to access the accounts permissions map. func NewAccountKeeper( - cdc codec.BinaryCodec, storeService store.KVStoreService, proto func() sdk.AccountI, + env appmodule.Environment, cdc codec.BinaryCodec, proto func() sdk.AccountI, maccPerms map[string][]string, ac address.Codec, bech32Prefix, authority string, ) AccountKeeper { permAddrs := make(map[string]types.PermissionsForAddress) @@ -119,12 +119,12 @@ func NewAccountKeeper( permAddrs[name] = types.NewPermissionsForAddress(name, perms) } - sb := collections.NewSchemaBuilder(storeService) + sb := collections.NewSchemaBuilder(env.KVStoreService) ak := AccountKeeper{ addressCodec: ac, bech32Prefix: bech32Prefix, - storeService: storeService, + Environment: env, proto: proto, cdc: cdc, permAddrs: permAddrs, @@ -154,7 +154,7 @@ func (ak AccountKeeper) AddressCodec() address.Codec { // Logger returns a module-specific logger. func (ak AccountKeeper) Logger(ctx context.Context) log.Logger { - return sdk.UnwrapSDKContext(ctx).Logger().With("module", "x/"+types.ModuleName) + return ak.Environment.Logger.With("module", "x/"+types.ModuleName) } // GetPubKey Returns the PubKey of the account at address diff --git a/x/auth/keeper/keeper_test.go b/x/auth/keeper/keeper_test.go index 57d7c7fd34..fa85083c0b 100644 --- a/x/auth/keeper/keeper_test.go +++ b/x/auth/keeper/keeper_test.go @@ -7,6 +7,7 @@ import ( "github.com/stretchr/testify/suite" "cosmossdk.io/core/header" + "cosmossdk.io/log" storetypes "cosmossdk.io/store/types" "cosmossdk.io/x/auth" authcodec "cosmossdk.io/x/auth/codec" @@ -49,6 +50,7 @@ func (suite *KeeperTestSuite) SetupTest() { key := storetypes.NewKVStoreKey(types.StoreKey) storeService := runtime.NewKVStoreService(key) + env := runtime.NewEnvironment(storeService, log.NewNopLogger()) testCtx := testutil.DefaultContextWithDB(suite.T(), key, storetypes.NewTransientStoreKey("transient_test")) suite.ctx = testCtx.Ctx.WithHeaderInfo(header.Info{}) @@ -62,8 +64,8 @@ func (suite *KeeperTestSuite) SetupTest() { } suite.accountKeeper = keeper.NewAccountKeeper( + env, suite.encCfg.Codec, - storeService, types.ProtoBaseAccount, maccPerms, authcodec.NewBech32Codec("cosmos"), diff --git a/x/auth/keeper/migrations.go b/x/auth/keeper/migrations.go index 2951a9d54b..cad0b57426 100644 --- a/x/auth/keeper/migrations.go +++ b/x/auth/keeper/migrations.go @@ -42,7 +42,7 @@ func (m Migrator) Migrate3to4(ctx context.Context) error { // It migrates the GlobalAccountNumber from being a protobuf defined value to a // big-endian encoded uint64, it also migrates it to use a more canonical prefix. func (m Migrator) Migrate4To5(ctx context.Context) error { - return v5.Migrate(ctx, m.keeper.storeService, m.keeper.AccountNumber) + return v5.Migrate(ctx, m.keeper.Environment.KVStoreService, m.keeper.AccountNumber) } // V45_SetAccount implements V45_SetAccount @@ -51,7 +51,7 @@ func (m Migrator) Migrate4To5(ctx context.Context) error { // NOTE: This is used for testing purposes only. func (m Migrator) V45SetAccount(ctx context.Context, acc sdk.AccountI) error { addr := acc.GetAddress() - store := m.keeper.storeService.OpenKVStore(ctx) + store := m.keeper.Environment.KVStoreService.OpenKVStore(ctx) bz, err := m.keeper.Accounts.ValueCodec().Encode(acc) if err != nil { diff --git a/x/auth/keeper/msg_server.go b/x/auth/keeper/msg_server.go index 1e1b4e0953..c66785af36 100644 --- a/x/auth/keeper/msg_server.go +++ b/x/auth/keeper/msg_server.go @@ -5,8 +5,6 @@ import ( "fmt" "cosmossdk.io/x/auth/types" - - sdk "github.com/cosmos/cosmos-sdk/types" ) var _ types.MsgServer = msgServer{} @@ -22,7 +20,7 @@ func NewMsgServerImpl(ak AccountKeeper) types.MsgServer { } } -func (ms msgServer) UpdateParams(goCtx context.Context, msg *types.MsgUpdateParams) (*types.MsgUpdateParamsResponse, error) { +func (ms msgServer) UpdateParams(ctx context.Context, msg *types.MsgUpdateParams) (*types.MsgUpdateParamsResponse, error) { if ms.ak.authority != msg.Authority { return nil, fmt.Errorf( "expected authority account as only signer for proposal message; invalid authority; expected %s, got %s", @@ -33,7 +31,6 @@ func (ms msgServer) UpdateParams(goCtx context.Context, msg *types.MsgUpdatePara return nil, err } - ctx := sdk.UnwrapSDKContext(goCtx) if err := ms.ak.Params.Set(ctx, msg.Params); err != nil { return nil, err } diff --git a/x/auth/vesting/fuzz_test.go b/x/auth/vesting/fuzz_test.go index fb5ad80426..a1036d616a 100644 --- a/x/auth/vesting/fuzz_test.go +++ b/x/auth/vesting/fuzz_test.go @@ -77,14 +77,13 @@ func FuzzMsgServerCreateVestingAccount(f *testing.F) { } key := storetypes.NewKVStoreKey(authtypes.StoreKey) - storeService := runtime.NewKVStoreService(key) - + env := runtime.NewEnvironment(runtime.NewKVStoreService(key), log.NewNopLogger()) maccPerms := map[string][]string{} encCfg := moduletestutil.MakeTestEncodingConfig() accountKeeper := authkeeper.NewAccountKeeper( + env, encCfg.Codec, - storeService, authtypes.ProtoBaseAccount, maccPerms, address.NewBech32Codec("cosmos"), @@ -103,6 +102,7 @@ func FuzzMsgServerCreateVestingAccount(f *testing.F) { return } + storeService := runtime.NewKVStoreService(key) ctrl := gomock.NewController(t) authKeeper := banktestutil.NewMockAccountKeeper(ctrl) authKeeper.EXPECT().AddressCodec().Return(address.NewBech32Codec("cosmos")).AnyTimes() diff --git a/x/auth/vesting/msg_server.go b/x/auth/vesting/msg_server.go index 91ddc9d0e9..e65cde63ce 100644 --- a/x/auth/vesting/msg_server.go +++ b/x/auth/vesting/msg_server.go @@ -80,8 +80,7 @@ func (s msgServer) CreateVestingAccount(ctx context.Context, msg *types.MsgCreat } else { start := msg.StartTime if msg.StartTime == 0 { - sdkctx := sdk.UnwrapSDKContext(ctx) - start = sdkctx.HeaderInfo().Time.Unix() + start = s.AccountKeeper.Environment.HeaderService.GetHeaderInfo(ctx).Time.Unix() } vestingAccount = types.NewContinuousVestingAccountRaw(baseVestingAccount, start) } diff --git a/x/auth/vesting/msg_server_test.go b/x/auth/vesting/msg_server_test.go index 0c8b020c38..df72946dae 100644 --- a/x/auth/vesting/msg_server_test.go +++ b/x/auth/vesting/msg_server_test.go @@ -8,6 +8,7 @@ import ( "github.com/stretchr/testify/suite" "cosmossdk.io/core/header" + "cosmossdk.io/log" "cosmossdk.io/math" storetypes "cosmossdk.io/store/types" authcodec "cosmossdk.io/x/auth/codec" @@ -43,7 +44,8 @@ type VestingTestSuite struct { func (s *VestingTestSuite) SetupTest() { key := storetypes.NewKVStoreKey(authtypes.StoreKey) - storeService := runtime.NewKVStoreService(key) + + env := runtime.NewEnvironment(runtime.NewKVStoreService(key), log.NewNopLogger()) testCtx := testutil.DefaultContextWithDB(s.T(), key, storetypes.NewTransientStoreKey("transient_test")) s.ctx = testCtx.Ctx.WithHeaderInfo(header.Info{Time: time.Now()}) @@ -54,8 +56,8 @@ func (s *VestingTestSuite) SetupTest() { ctrl := gomock.NewController(s.T()) s.bankKeeper = vestingtestutil.NewMockBankKeeper(ctrl) s.accountKeeper = authkeeper.NewAccountKeeper( + env, encCfg.Codec, - storeService, authtypes.ProtoBaseAccount, maccPerms, authcodec.NewBech32Codec("cosmos"), diff --git a/x/auth/vesting/types/vesting_account_test.go b/x/auth/vesting/types/vesting_account_test.go index 011445350d..3c1756c59d 100644 --- a/x/auth/vesting/types/vesting_account_test.go +++ b/x/auth/vesting/types/vesting_account_test.go @@ -8,6 +8,7 @@ import ( "github.com/stretchr/testify/suite" "cosmossdk.io/core/header" + "cosmossdk.io/log" storetypes "cosmossdk.io/store/types" authcodec "cosmossdk.io/x/auth/codec" "cosmossdk.io/x/auth/keeper" @@ -40,7 +41,7 @@ func (s *VestingAccountTestSuite) SetupTest() { encCfg := moduletestutil.MakeTestEncodingConfig(vesting.AppModuleBasic{}) key := storetypes.NewKVStoreKey(authtypes.StoreKey) - storeService := runtime.NewKVStoreService(key) + env := runtime.NewEnvironment(runtime.NewKVStoreService(key), log.NewNopLogger()) testCtx := testutil.DefaultContextWithDB(s.T(), key, storetypes.NewTransientStoreKey("transient_test")) s.ctx = testCtx.Ctx.WithHeaderInfo(header.Info{}) @@ -54,8 +55,8 @@ func (s *VestingAccountTestSuite) SetupTest() { } s.accountKeeper = keeper.NewAccountKeeper( + env, encCfg.Codec, - storeService, authtypes.ProtoBaseAccount, maccPerms, authcodec.NewBech32Codec("cosmos"), diff --git a/x/distribution/migrations/v4/migrate_funds_test.go b/x/distribution/migrations/v4/migrate_funds_test.go index b353e111c1..e2d166e2de 100644 --- a/x/distribution/migrations/v4/migrate_funds_test.go +++ b/x/distribution/migrations/v4/migrate_funds_test.go @@ -46,8 +46,8 @@ func TestFundsMigration(t *testing.T) { // create account keeper accountKeeper := authkeeper.NewAccountKeeper( + runtime.NewEnvironment(runtime.NewKVStoreService(keys[authtypes.StoreKey]), log.NewNopLogger()), encCfg.Codec, - runtime.NewKVStoreService(keys[authtypes.StoreKey]), authtypes.ProtoBaseAccount, maccPerms, addresscodec.NewBech32Codec(sdk.Bech32MainPrefix), diff --git a/x/group/migrations/v2/migrate_test.go b/x/group/migrations/v2/migrate_test.go index ed60eab541..b83c014cd9 100644 --- a/x/group/migrations/v2/migrate_test.go +++ b/x/group/migrations/v2/migrate_test.go @@ -6,6 +6,7 @@ import ( "github.com/stretchr/testify/require" corestore "cosmossdk.io/core/store" + "cosmossdk.io/log" storetypes "cosmossdk.io/store/types" "cosmossdk.io/x/auth" authkeeper "cosmossdk.io/x/auth/keeper" @@ -82,7 +83,7 @@ func createGroupPolicies(ctx sdk.Context, storeService corestore.KVStoreService, // createOldPolicyAccount re-creates the group policy account using a module account func createOldPolicyAccount(ctx sdk.Context, storeKey storetypes.StoreKey, cdc codec.Codec, policies []sdk.AccAddress) ([]*authtypes.ModuleAccount, group.AccountKeeper) { - accountKeeper := authkeeper.NewAccountKeeper(cdc, runtime.NewKVStoreService(storeKey.(*storetypes.KVStoreKey)), authtypes.ProtoBaseAccount, nil, addresscodec.NewBech32Codec(sdk.Bech32MainPrefix), sdk.Bech32MainPrefix, authorityAddr.String()) + accountKeeper := authkeeper.NewAccountKeeper(runtime.NewEnvironment(runtime.NewKVStoreService(storeKey.(*storetypes.KVStoreKey)), log.NewNopLogger()), cdc, authtypes.ProtoBaseAccount, nil, addresscodec.NewBech32Codec(sdk.Bech32MainPrefix), sdk.Bech32MainPrefix, authorityAddr.String()) oldPolicyAccounts := make([]*authtypes.ModuleAccount, len(policies)) for i, policyAddr := range policies {