Skip to content

Commit

Permalink
fix: fixed voting power update if validator is unbonded
Browse files Browse the repository at this point in the history
  • Loading branch information
RiccardoM committed Oct 20, 2023
1 parent 4f987d6 commit fdf851c
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions modules/staking/utils_validators.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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(),
Expand Down

0 comments on commit fdf851c

Please sign in to comment.