From 95d873faebd19392ec1368653add86e838d286df Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Tue, 7 Jun 2022 17:34:57 -0400 Subject: [PATCH] chore: remove direct reliance on staking from slashing (backport #12177) (#12181) --- x/distribution/module.go | 5 ++--- x/distribution/simulation/operations.go | 14 ++++++-------- x/slashing/module.go | 5 ++--- x/slashing/simulation/operations.go | 4 ++-- 4 files changed, 12 insertions(+), 16 deletions(-) diff --git a/x/distribution/module.go b/x/distribution/module.go index b2dec5b30167..257747f36df6 100644 --- a/x/distribution/module.go +++ b/x/distribution/module.go @@ -23,7 +23,6 @@ import ( "github.com/cosmos/cosmos-sdk/x/distribution/keeper" "github.com/cosmos/cosmos-sdk/x/distribution/simulation" "github.com/cosmos/cosmos-sdk/x/distribution/types" - stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper" ) var ( @@ -95,13 +94,13 @@ type AppModule struct { keeper keeper.Keeper accountKeeper types.AccountKeeper bankKeeper types.BankKeeper - stakingKeeper stakingkeeper.Keeper + stakingKeeper types.StakingKeeper } // NewAppModule creates a new AppModule object func NewAppModule( cdc codec.Codec, keeper keeper.Keeper, accountKeeper types.AccountKeeper, - bankKeeper types.BankKeeper, stakingKeeper stakingkeeper.Keeper, + bankKeeper types.BankKeeper, stakingKeeper types.StakingKeeper, ) AppModule { return AppModule{ AppModuleBasic: AppModuleBasic{cdc: cdc}, diff --git a/x/distribution/simulation/operations.go b/x/distribution/simulation/operations.go index f82e921290b4..4aee32eb2f5c 100644 --- a/x/distribution/simulation/operations.go +++ b/x/distribution/simulation/operations.go @@ -24,11 +24,7 @@ const ( ) // WeightedOperations returns all the operations from the module with their respective weights -func WeightedOperations( - appParams simtypes.AppParams, cdc codec.JSONCodec, ak types.AccountKeeper, - bk types.BankKeeper, k keeper.Keeper, sk stakingkeeper.Keeper, -) simulation.WeightedOperations { - +func WeightedOperations(appParams simtypes.AppParams, cdc codec.JSONCodec, ak types.AccountKeeper, bk types.BankKeeper, k keeper.Keeper, sk types.StakingKeeper) simulation.WeightedOperations { var weightMsgSetWithdrawAddress int appParams.GetOrGenerate(cdc, OpWeightMsgSetWithdrawAddress, &weightMsgSetWithdrawAddress, nil, func(_ *rand.Rand) { @@ -57,6 +53,8 @@ func WeightedOperations( }, ) + stakeKeeper := sk.(stakingkeeper.Keeper) + return simulation.WeightedOperations{ simulation.NewWeightedOperation( weightMsgSetWithdrawAddress, @@ -64,15 +62,15 @@ func WeightedOperations( ), simulation.NewWeightedOperation( weightMsgWithdrawDelegationReward, - SimulateMsgWithdrawDelegatorReward(ak, bk, k, sk), + SimulateMsgWithdrawDelegatorReward(ak, bk, k, stakeKeeper), ), simulation.NewWeightedOperation( weightMsgWithdrawValidatorCommission, - SimulateMsgWithdrawValidatorCommission(ak, bk, k, sk), + SimulateMsgWithdrawValidatorCommission(ak, bk, k, stakeKeeper), ), simulation.NewWeightedOperation( weightMsgFundCommunityPool, - SimulateMsgFundCommunityPool(ak, bk, k, sk), + SimulateMsgFundCommunityPool(ak, bk, k, stakeKeeper), ), } } diff --git a/x/slashing/module.go b/x/slashing/module.go index d837a16e5c01..5b4412fbd12f 100644 --- a/x/slashing/module.go +++ b/x/slashing/module.go @@ -24,7 +24,6 @@ import ( "github.com/cosmos/cosmos-sdk/x/slashing/keeper" "github.com/cosmos/cosmos-sdk/x/slashing/simulation" "github.com/cosmos/cosmos-sdk/x/slashing/types" - stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper" ) var ( @@ -98,11 +97,11 @@ type AppModule struct { keeper keeper.Keeper accountKeeper types.AccountKeeper bankKeeper types.BankKeeper - stakingKeeper stakingkeeper.Keeper + stakingKeeper types.StakingKeeper } // NewAppModule creates a new AppModule object -func NewAppModule(cdc codec.Codec, keeper keeper.Keeper, ak types.AccountKeeper, bk types.BankKeeper, sk stakingkeeper.Keeper) AppModule { +func NewAppModule(cdc codec.Codec, keeper keeper.Keeper, ak types.AccountKeeper, bk types.BankKeeper, sk types.StakingKeeper) AppModule { return AppModule{ AppModuleBasic: AppModuleBasic{cdc: cdc}, keeper: keeper, diff --git a/x/slashing/simulation/operations.go b/x/slashing/simulation/operations.go index 3b98b2af05a4..a34cc24bbb57 100644 --- a/x/slashing/simulation/operations.go +++ b/x/slashing/simulation/operations.go @@ -24,7 +24,7 @@ const ( // WeightedOperations returns all the operations from the module with their respective weights func WeightedOperations( appParams simtypes.AppParams, cdc codec.JSONCodec, ak types.AccountKeeper, - bk types.BankKeeper, k keeper.Keeper, sk stakingkeeper.Keeper, + bk types.BankKeeper, k keeper.Keeper, sk types.StakingKeeper, ) simulation.WeightedOperations { var weightMsgUnjail int @@ -37,7 +37,7 @@ func WeightedOperations( return simulation.WeightedOperations{ simulation.NewWeightedOperation( weightMsgUnjail, - SimulateMsgUnjail(ak, bk, k, sk), + SimulateMsgUnjail(ak, bk, k, sk.(stakingkeeper.Keeper)), ), } }