Skip to content

Commit

Permalink
chore: remove direct reliance on staking from slashing (backport cosm…
Browse files Browse the repository at this point in the history
  • Loading branch information
mergify[bot] authored and JeancarloBarrios committed Sep 28, 2024
1 parent 802e22d commit 8b95d1c
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 8 deletions.
26 changes: 20 additions & 6 deletions x/distribution/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
simtypes "github.com/cosmos/cosmos-sdk/types/simulation"
"github.com/cosmos/cosmos-sdk/x/distribution/client/cli"
"github.com/cosmos/cosmos-sdk/x/distribution/client/rest"
"github.com/cosmos/cosmos-sdk/x/distribution/keeper"
"github.com/cosmos/cosmos-sdk/x/distribution/simulation"
"github.com/cosmos/cosmos-sdk/x/distribution/types"
)

// ConsensusVersion defines the current x/distribution module consensus version.
Expand Down Expand Up @@ -97,14 +102,23 @@ func (am AppModule) RegisterServices(registrar grpc.ServiceRegistrar) error {
types.RegisterMsgServer(registrar, keeper.NewMsgServerImpl(am.keeper))
types.RegisterQueryServer(registrar, keeper.NewQuerier(am.keeper))

return nil
keeper keeper.Keeper
accountKeeper types.AccountKeeper
bankKeeper types.BankKeeper
stakingKeeper types.StakingKeeper
}

// RegisterMigrations registers the distribution module's migrations.
func (am AppModule) RegisterMigrations(mr appmodule.MigrationRegistrar) error {
m := keeper.NewMigrator(am.keeper)
if err := mr.Register(types.ModuleName, 1, m.Migrate1to2); err != nil {
return fmt.Errorf("failed to migrate x/%s from version 1 to 2: %w", types.ModuleName, err)
// NewAppModule creates a new AppModule object
func NewAppModule(
cdc codec.Codec, keeper keeper.Keeper, accountKeeper types.AccountKeeper,
bankKeeper types.BankKeeper, stakingKeeper types.StakingKeeper,
) AppModule {
return AppModule{
AppModuleBasic: AppModuleBasic{cdc: cdc},
keeper: keeper,
accountKeeper: accountKeeper,
bankKeeper: bankKeeper,
stakingKeeper: stakingKeeper,
}

if err := mr.Register(types.ModuleName, 2, m.Migrate2to3); err != nil {
Expand Down
21 changes: 19 additions & 2 deletions x/slashing/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ import (
"github.com/cosmos/cosmos-sdk/simsx"
"github.com/cosmos/cosmos-sdk/types/module"
simtypes "github.com/cosmos/cosmos-sdk/types/simulation"
"github.com/cosmos/cosmos-sdk/x/slashing/client/cli"
"github.com/cosmos/cosmos-sdk/x/slashing/client/rest"
"github.com/cosmos/cosmos-sdk/x/slashing/keeper"
"github.com/cosmos/cosmos-sdk/x/slashing/simulation"
"github.com/cosmos/cosmos-sdk/x/slashing/types"
)

// ConsensusVersion defines the current x/slashing module consensus version.
Expand Down Expand Up @@ -103,8 +108,20 @@ func (am AppModule) RegisterServices(registrar grpc.ServiceRegistrar) error {
func (am AppModule) RegisterMigrations(mr appmodule.MigrationRegistrar) error {
m := keeper.NewMigrator(am.keeper, am.stakingKeeper.ValidatorAddressCodec())

if err := mr.Register(types.ModuleName, 1, m.Migrate1to2); err != nil {
return fmt.Errorf("failed to migrate x/%s from version 1 to 2: %w", types.ModuleName, err)
keeper keeper.Keeper
accountKeeper types.AccountKeeper
bankKeeper types.BankKeeper
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 {
return AppModule{
AppModuleBasic: AppModuleBasic{cdc: cdc},
keeper: keeper,
accountKeeper: ak,
bankKeeper: bk,
stakingKeeper: sk,
}

if err := mr.Register(types.ModuleName, 2, m.Migrate2to3); err != nil {
Expand Down

0 comments on commit 8b95d1c

Please sign in to comment.