Skip to content

Commit

Permalink
chore: fix ValidatorSet.ValidateBlockCommitValidators() behavior for …
Browse files Browse the repository at this point in the history
…null validator power
  • Loading branch information
limebell committed Jun 14, 2024
1 parent c9ace8f commit 4edceb2
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion Libplanet.Types/Consensus/ValidatorSet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,8 @@ public Validator GetProposer(long height, int round)
/// by <see cref="Address"/> of each <see cref="Vote.ValidatorPublicKey"/>,
/// and <see cref="Vote.ValidatorPower"/> equals to the one recorded in the chain states.
/// </summary>
/// <remarks>
/// If <see cref="Vote.ValidatorPower"/> is null, power check is ignored.</remarks>
/// <param name="blockCommit">The <see cref="BlockCommit"/> to check.</param>
/// <returns><see langword="true"/> if the <see cref="BlockCommit.Votes"/> is
/// ordered, <see langword="false"/> otherwise.</returns>
Expand All @@ -261,7 +263,8 @@ public bool ValidateBlockCommitValidators(BlockCommit blockCommit)
.SequenceEqual(
blockCommit.Votes.Select(vote => vote.ValidatorPublicKey).ToList()) &&
blockCommit.Votes.All(
v => v.ValidatorPower == GetValidator(v.ValidatorPublicKey).Power);
v => v.ValidatorPower is null ||
v.ValidatorPower == GetValidator(v.ValidatorPublicKey).Power);
}
}
}

0 comments on commit 4edceb2

Please sign in to comment.