diff --git a/x/slashing/handler.go b/x/slashing/handler.go index 43ea6a8b7..8945c5462 100644 --- a/x/slashing/handler.go +++ b/x/slashing/handler.go @@ -3,6 +3,8 @@ package slashing import ( sdk "github.com/okx/okbchain/libs/cosmos-sdk/types" sdkerrors "github.com/okx/okbchain/libs/cosmos-sdk/types/errors" + types2 "github.com/okx/okbchain/libs/tendermint/types" + "github.com/okx/okbchain/x/common" "github.com/okx/okbchain/x/slashing/internal/types" ) @@ -29,7 +31,12 @@ func handleMsgUnjail(ctx sdk.Context, msg MsgUnjail, k Keeper) (*sdk.Result, err return nil, sdkerrors.Wrapf(ErrNoValidatorForAddress, "Unjail failed") } - if validator.GetMinSelfDelegation().IsZero() { + checkSelfDelegation := true + if types2.HigherThanEarth(ctx.BlockHeight()) && k.GetStakingKeeper().ParamsConsensusType(ctx) == common.PoA { + checkSelfDelegation = false + } + + if checkSelfDelegation && validator.GetMinSelfDelegation().IsZero() { return nil, sdkerrors.Wrapf(ErrMissingSelfDelegation, "Unjail failed") } diff --git a/x/slashing/internal/types/expected_keepers.go b/x/slashing/internal/types/expected_keepers.go index be516e96d..99d5b76f3 100644 --- a/x/slashing/internal/types/expected_keepers.go +++ b/x/slashing/internal/types/expected_keepers.go @@ -5,6 +5,7 @@ package types import ( sdk "github.com/okx/okbchain/libs/cosmos-sdk/types" authexported "github.com/okx/okbchain/libs/cosmos-sdk/x/auth/exported" + "github.com/okx/okbchain/x/common" "github.com/okx/okbchain/x/params" stakingexported "github.com/okx/okbchain/x/staking/exported" ) @@ -46,6 +47,8 @@ type StakingKeeper interface { //Append abandoned validator to staking keeper AppendAbandonedValidatorAddrs(ctx sdk.Context, ConsAddr sdk.ConsAddress) + + ParamsConsensusType(ctx sdk.Context) (consensusType common.ConsensusType) } // StakingHooks event hooks for staking validator object (noalias) diff --git a/x/staking/keeper/val_state_change.go b/x/staking/keeper/val_state_change.go index 0a66e039e..899bfd5d7 100644 --- a/x/staking/keeper/val_state_change.go +++ b/x/staking/keeper/val_state_change.go @@ -7,6 +7,7 @@ import ( sdk "github.com/okx/okbchain/libs/cosmos-sdk/types" abci "github.com/okx/okbchain/libs/tendermint/abci/types" + "github.com/okx/okbchain/x/common" "github.com/okx/okbchain/x/staking/types" ) @@ -244,6 +245,10 @@ func (k Keeper) unjailValidator(ctx sdk.Context, validator types.Validator) { validator.Jailed = false k.SetValidator(ctx, validator) k.SetValidatorByPowerIndex(ctx, validator) + + if k.ParamsConsensusType(ctx) == common.PoA { + k.SetProposeValidator(ctx, validator.OperatorAddress, true) + } } // bondValidator performs all the store operations for when a validator status becomes bonded