From f731ca5d414077690e33a2d9b8927ba60d14ed42 Mon Sep 17 00:00:00 2001 From: Peter Bukva Date: Fri, 25 Oct 2024 14:04:50 +0100 Subject: [PATCH] Relaxing degree of freedom for target validator to receive delegations --- app/upgrade_cudos.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/app/upgrade_cudos.go b/app/upgrade_cudos.go index add353a3..697400df 100644 --- a/app/upgrade_cudos.go +++ b/app/upgrade_cudos.go @@ -1099,6 +1099,10 @@ func withdrawGenesisStakingDelegations(logger log.Logger, genesisData *GenesisDa return nil } +func canReceiveDelegations(targetValidator *stakingtypes.Validator) bool { + return targetValidator != nil && !targetValidator.Jailed +} + func resolveDestinationValidator(ctx sdk.Context, app *App, operatorAddress string, cudosCfg *CudosMergeConfig) (*stakingtypes.Validator, error) { if targetOperatorStringAddress, exists := cudosCfg.ValidatorsMap.Get(operatorAddress); exists { targetOperatorAddress, err := sdk.ValAddressFromBech32(targetOperatorStringAddress) @@ -1107,11 +1111,10 @@ func resolveDestinationValidator(ctx sdk.Context, app *App, operatorAddress stri } if targetValidator, found := app.StakingKeeper.GetValidator(ctx, targetOperatorAddress); found { - if targetValidator.Status.String() == BondedStatus && !targetValidator.Jailed { + if canReceiveDelegations(&targetValidator) { return &targetValidator, nil } } - } for _, targetOperatorStringAddress := range cudosCfg.Config.BackupValidators { @@ -1121,7 +1124,7 @@ func resolveDestinationValidator(ctx sdk.Context, app *App, operatorAddress stri } if targetValidator, found := app.StakingKeeper.GetValidator(ctx, targetOperatorAddress); found { - if targetValidator.Status.String() == BondedStatus && !targetValidator.Jailed { + if canReceiveDelegations(&targetValidator) { return &targetValidator, nil } }