Skip to content

Commit

Permalink
chore: remove direct reliance on staking from slashing (#12177)
Browse files Browse the repository at this point in the history
(cherry picked from commit 7c4e4c1)

# Conflicts:
#	go.sum
#	x/distribution/module.go
#	x/distribution/simulation/operations.go
#	x/slashing/module.go
#	x/slashing/simulation/operations.go
  • Loading branch information
tac0turtle authored and mergify[bot] committed Jun 7, 2022
1 parent d721a76 commit ba74679
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 6 deletions.
5 changes: 5 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,12 @@ github.com/coreos/pkg v0.0.0-20160727233714-3ac0863d7acf/go.mod h1:E3G3o1h8I7cfc
github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA=
github.com/cosmos/btcutil v1.0.4 h1:n7C2ngKXo7UC9gNyMNLbzqz7Asuf+7Qv4gnX/rOdQ44=
github.com/cosmos/btcutil v1.0.4/go.mod h1:Ffqc8Hn6TJUdDgHBwIZLtrLQC1KdJ9jGJl/TvgUaxbU=
<<<<<<< HEAD
github.com/cosmos/go-bip39 v0.0.0-20180819234021-555e2067c45d/go.mod h1:tSxLoYXyBmiFeKpvmq4dzayMdCjCnu8uqmCysIGBT2Y=
=======
github.com/cosmos/cosmos-proto v1.0.0-alpha7 h1:yqYUOHF2jopwZh4dVQp3xgqwftE5/2hkrwIV6vkUbO0=
github.com/cosmos/cosmos-proto v1.0.0-alpha7/go.mod h1:dosO4pSAbJF8zWCzCoTWP7nNsjcvSUBQmniFxDg5daw=
>>>>>>> 7c4e4c1a4 (chore: remove direct reliance on staking from slashing (#12177))
github.com/cosmos/go-bip39 v1.0.0 h1:pcomnQdrdH22njcAatO0yWojsUnCO3y2tNoV1cb6hHY=
github.com/cosmos/go-bip39 v1.0.0/go.mod h1:RNJv0H/pOIVgxw6KS7QeX2a0Uo0aKUlfhZ4xuwvCdJw=
github.com/cosmos/iavl v0.17.3 h1:s2N819a2olOmiauVa0WAhoIJq9EhSXE9HDBAoR9k+8Y=
Expand Down
9 changes: 8 additions & 1 deletion 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,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},
Expand Down
12 changes: 9 additions & 3 deletions x/distribution/simulation/operations.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,15 @@ 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) {
Expand Down Expand Up @@ -57,22 +61,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
9 changes: 8 additions & 1 deletion 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,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,
Expand Down
6 changes: 5 additions & 1 deletion x/slashing/simulation/operations.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -37,7 +41,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 ba74679

Please sign in to comment.