From ba21ff5c95a56093290cf9c5e10f1ede5ec0d511 Mon Sep 17 00:00:00 2001 From: Marko Date: Tue, 7 Jun 2022 20:42:46 +0200 Subject: [PATCH 1/2] chore: remove direct reliance on staking from slashing (#12177) (cherry picked from commit 7c4e4c1a44f3770c10956222b14b1f1595424172) # Conflicts: # x/distribution/module.go # x/distribution/simulation/operations.go # x/slashing/module.go # x/slashing/simulation/operations.go --- x/distribution/module.go | 9 ++++++++- x/distribution/simulation/operations.go | 12 +++++++++--- x/slashing/module.go | 9 ++++++++- x/slashing/simulation/operations.go | 6 +++++- 4 files changed, 30 insertions(+), 6 deletions(-) diff --git a/x/distribution/module.go b/x/distribution/module.go index e2f240b1edaf..b76d27b267ef 100644 --- a/x/distribution/module.go +++ b/x/distribution/module.go @@ -20,7 +20,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 ( @@ -89,13 +88,21 @@ type AppModule struct { keeper keeper.Keeper accountKeeper types.AccountKeeper bankKeeper types.BankKeeper +<<<<<<< HEAD stakingKeeper stakingkeeper.Keeper +======= + stakingKeeper types.StakingKeeper +>>>>>>> 7c4e4c1a4 (chore: remove direct reliance on staking from slashing (#12177)) } // NewAppModule creates a new AppModule object func NewAppModule( cdc codec.Codec, keeper keeper.Keeper, accountKeeper types.AccountKeeper, +<<<<<<< HEAD bankKeeper types.BankKeeper, stakingKeeper stakingkeeper.Keeper, +======= + bankKeeper types.BankKeeper, stakingKeeper types.StakingKeeper, +>>>>>>> 7c4e4c1a4 (chore: remove direct reliance on staking from slashing (#12177)) ) AppModule { return AppModule{ AppModuleBasic: AppModuleBasic{cdc: cdc}, diff --git a/x/distribution/simulation/operations.go b/x/distribution/simulation/operations.go index 44aa71a8e156..469361a2124e 100644 --- a/x/distribution/simulation/operations.go +++ b/x/distribution/simulation/operations.go @@ -24,10 +24,14 @@ const ( ) // WeightedOperations returns all the operations from the module with their respective weights +<<<<<<< HEAD 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 { +>>>>>>> 7c4e4c1a4 (chore: remove direct reliance on staking from slashing (#12177)) var weightMsgSetWithdrawAddress int appParams.GetOrGenerate(cdc, OpWeightMsgSetWithdrawAddress, &weightMsgSetWithdrawAddress, nil, func(_ *rand.Rand) { @@ -56,6 +60,8 @@ func WeightedOperations( }, ) + stakeKeeper := sk.(*stakingkeeper.Keeper) + return simulation.WeightedOperations{ simulation.NewWeightedOperation( weightMsgSetWithdrawAddress, @@ -63,15 +69,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 73991883aa03..8e9a905128b8 100644 --- a/x/slashing/module.go +++ b/x/slashing/module.go @@ -20,7 +20,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 ( @@ -91,11 +90,19 @@ type AppModule struct { keeper keeper.Keeper accountKeeper types.AccountKeeper bankKeeper types.BankKeeper +<<<<<<< HEAD stakingKeeper stakingkeeper.Keeper } // NewAppModule creates a new AppModule object func NewAppModule(cdc codec.Codec, keeper keeper.Keeper, ak types.AccountKeeper, bk types.BankKeeper, sk stakingkeeper.Keeper) AppModule { +======= + stakingKeeper types.StakingKeeper +} + +// NewAppModule creates a new AppModule object +func NewAppModule(cdc codec.Codec, keeper keeper.Keeper, ak types.AccountKeeper, bk types.BankKeeper, sk types.StakingKeeper) AppModule { +>>>>>>> 7c4e4c1a4 (chore: remove direct reliance on staking from slashing (#12177)) return AppModule{ AppModuleBasic: AppModuleBasic{cdc: cdc}, keeper: keeper, diff --git a/x/slashing/simulation/operations.go b/x/slashing/simulation/operations.go index 56eef65d8a57..e2f8c5e3ca68 100644 --- a/x/slashing/simulation/operations.go +++ b/x/slashing/simulation/operations.go @@ -24,7 +24,11 @@ const ( // WeightedOperations returns all the operations from the module with their respective weights func WeightedOperations( appParams simtypes.AppParams, cdc codec.JSONCodec, ak types.AccountKeeper, +<<<<<<< HEAD bk types.BankKeeper, k keeper.Keeper, sk stakingkeeper.Keeper, +======= + bk types.BankKeeper, k keeper.Keeper, sk types.StakingKeeper, +>>>>>>> 7c4e4c1a4 (chore: remove direct reliance on staking from slashing (#12177)) ) simulation.WeightedOperations { var weightMsgUnjail int appParams.GetOrGenerate(cdc, OpWeightMsgUnjail, &weightMsgUnjail, nil, @@ -36,7 +40,7 @@ func WeightedOperations( return simulation.WeightedOperations{ simulation.NewWeightedOperation( weightMsgUnjail, - SimulateMsgUnjail(ak, bk, k, sk), + SimulateMsgUnjail(ak, bk, k, sk.(*stakingkeeper.Keeper)), ), } } From d5e02a1ba69e0431f044ac8726b7c4b22acfade2 Mon Sep 17 00:00:00 2001 From: marbar3778 Date: Tue, 7 Jun 2022 22:29:28 +0200 Subject: [PATCH 2/2] fix conflict --- x/distribution/module.go | 8 -------- x/distribution/simulation/operations.go | 9 +-------- x/slashing/module.go | 8 -------- x/slashing/simulation/operations.go | 6 +----- 4 files changed, 2 insertions(+), 29 deletions(-) diff --git a/x/distribution/module.go b/x/distribution/module.go index b76d27b267ef..dc54a64a9b77 100644 --- a/x/distribution/module.go +++ b/x/distribution/module.go @@ -88,21 +88,13 @@ type AppModule struct { keeper keeper.Keeper accountKeeper types.AccountKeeper bankKeeper types.BankKeeper -<<<<<<< HEAD - stakingKeeper stakingkeeper.Keeper -======= stakingKeeper types.StakingKeeper ->>>>>>> 7c4e4c1a4 (chore: remove direct reliance on staking from slashing (#12177)) } // NewAppModule creates a new AppModule object func NewAppModule( cdc codec.Codec, keeper keeper.Keeper, accountKeeper types.AccountKeeper, -<<<<<<< HEAD - bankKeeper types.BankKeeper, stakingKeeper stakingkeeper.Keeper, -======= bankKeeper types.BankKeeper, stakingKeeper types.StakingKeeper, ->>>>>>> 7c4e4c1a4 (chore: remove direct reliance on staking from slashing (#12177)) ) AppModule { return AppModule{ AppModuleBasic: AppModuleBasic{cdc: cdc}, diff --git a/x/distribution/simulation/operations.go b/x/distribution/simulation/operations.go index 469361a2124e..c76318fe82cd 100644 --- a/x/distribution/simulation/operations.go +++ b/x/distribution/simulation/operations.go @@ -24,14 +24,7 @@ const ( ) // WeightedOperations returns all the operations from the module with their respective weights -<<<<<<< HEAD -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 { ->>>>>>> 7c4e4c1a4 (chore: remove direct reliance on staking from slashing (#12177)) var weightMsgSetWithdrawAddress int appParams.GetOrGenerate(cdc, OpWeightMsgSetWithdrawAddress, &weightMsgSetWithdrawAddress, nil, func(_ *rand.Rand) { @@ -60,7 +53,7 @@ func WeightedOperations(appParams simtypes.AppParams, cdc codec.JSONCodec, ak ty }, ) - stakeKeeper := sk.(*stakingkeeper.Keeper) + stakeKeeper := sk.(stakingkeeper.Keeper) return simulation.WeightedOperations{ simulation.NewWeightedOperation( diff --git a/x/slashing/module.go b/x/slashing/module.go index 8e9a905128b8..47f2aec83872 100644 --- a/x/slashing/module.go +++ b/x/slashing/module.go @@ -90,19 +90,11 @@ type AppModule struct { keeper keeper.Keeper accountKeeper types.AccountKeeper bankKeeper types.BankKeeper -<<<<<<< HEAD - stakingKeeper stakingkeeper.Keeper -} - -// NewAppModule creates a new AppModule object -func NewAppModule(cdc codec.Codec, keeper keeper.Keeper, ak types.AccountKeeper, bk types.BankKeeper, sk stakingkeeper.Keeper) AppModule { -======= stakingKeeper types.StakingKeeper } // NewAppModule creates a new AppModule object func NewAppModule(cdc codec.Codec, keeper keeper.Keeper, ak types.AccountKeeper, bk types.BankKeeper, sk types.StakingKeeper) AppModule { ->>>>>>> 7c4e4c1a4 (chore: remove direct reliance on staking from slashing (#12177)) return AppModule{ AppModuleBasic: AppModuleBasic{cdc: cdc}, keeper: keeper, diff --git a/x/slashing/simulation/operations.go b/x/slashing/simulation/operations.go index e2f8c5e3ca68..eabe6486b7bc 100644 --- a/x/slashing/simulation/operations.go +++ b/x/slashing/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, -<<<<<<< HEAD - bk types.BankKeeper, k keeper.Keeper, sk stakingkeeper.Keeper, -======= bk types.BankKeeper, k keeper.Keeper, sk types.StakingKeeper, ->>>>>>> 7c4e4c1a4 (chore: remove direct reliance on staking from slashing (#12177)) ) simulation.WeightedOperations { var weightMsgUnjail int appParams.GetOrGenerate(cdc, OpWeightMsgUnjail, &weightMsgUnjail, nil, @@ -40,7 +36,7 @@ func WeightedOperations( return simulation.WeightedOperations{ simulation.NewWeightedOperation( weightMsgUnjail, - SimulateMsgUnjail(ak, bk, k, sk.(*stakingkeeper.Keeper)), + SimulateMsgUnjail(ak, bk, k, sk.(stakingkeeper.Keeper)), ), } }