From fdf851c892f29ae63c63e0b063dadf71309c0d69 Mon Sep 17 00:00:00 2001 From: Riccardo Montagnin Date: Fri, 20 Oct 2023 11:05:18 -0500 Subject: [PATCH] fix: fixed voting power update if validator is unbonded --- modules/staking/utils_validators.go | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/modules/staking/utils_validators.go b/modules/staking/utils_validators.go index 30c3005b9..9fa5597f0 100644 --- a/modules/staking/utils_validators.go +++ b/modules/staking/utils_validators.go @@ -262,10 +262,15 @@ func (m *Module) updateProposalValidatorStatusSnapshot(height int64, proposalID return err } + var votingPower = validator.Tokens.Int64() + if validator.Status != stakingtypes.Bonded || validator.IsJailed() { + votingPower = 0 + } + snapshots[index] = types.NewProposalValidatorStatusSnapshot( proposalID, consAddr.String(), - validator.Tokens.Int64(), + votingPower, validator.Status, validator.Jailed, height, @@ -298,7 +303,16 @@ func (m *Module) updateValidatorsStatusesAndVotingPowers(height int64, validator return err } - votingPowers[index] = types.NewValidatorVotingPower(consAddr.String(), validator.Tokens.Int64(), height) + var votingPower = validator.Tokens.Int64() + if validator.Status != stakingtypes.Bonded || validator.IsJailed() { + votingPower = 0 + } + + votingPowers[index] = types.NewValidatorVotingPower( + consAddr.String(), + votingPower, + height, + ) statuses[index] = types.NewValidatorStatus( consAddr.String(),