Skip to content

Commit

Permalink
chore: remove direct reliance on staking from slashing (backport #12177
Browse files Browse the repository at this point in the history
…) (#12181)
  • Loading branch information
mergify[bot] committed Jun 7, 2022
1 parent bec98b5 commit 95d873f
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 16 deletions.
5 changes: 2 additions & 3 deletions x/distribution/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down Expand Up @@ -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},
Expand Down
14 changes: 6 additions & 8 deletions x/distribution/simulation/operations.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -57,22 +53,24 @@ func WeightedOperations(
},
)

stakeKeeper := sk.(stakingkeeper.Keeper)

return simulation.WeightedOperations{
simulation.NewWeightedOperation(
weightMsgSetWithdrawAddress,
SimulateMsgSetWithdrawAddress(ak, bk, k),
),
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),
),
}
}
Expand Down
5 changes: 2 additions & 3 deletions x/slashing/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions x/slashing/simulation/operations.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -37,7 +37,7 @@ func WeightedOperations(
return simulation.WeightedOperations{
simulation.NewWeightedOperation(
weightMsgUnjail,
SimulateMsgUnjail(ak, bk, k, sk),
SimulateMsgUnjail(ak, bk, k, sk.(stakingkeeper.Keeper)),
),
}
}
Expand Down

0 comments on commit 95d873f

Please sign in to comment.