Skip to content

Commit

Permalink
Relaxing degree of freedom for target validator to receive delegations
Browse files Browse the repository at this point in the history
  • Loading branch information
pbukva committed Oct 25, 2024
1 parent e6d2955 commit f731ca5
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions app/upgrade_cudos.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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 {
Expand All @@ -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
}
}
Expand Down

0 comments on commit f731ca5

Please sign in to comment.