Skip to content

Commit

Permalink
feat: Remove Vote.Verify()
Browse files Browse the repository at this point in the history
  • Loading branch information
OnedgeLee committed Jun 20, 2024
1 parent dd7f770 commit f13ade5
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 20 deletions.
2 changes: 2 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ To be released.
[[#3811]]
- (Libplanet) `BlockChain.DetermineBlockStateRootHash()`
has been removed. [[#3811]]
- (Libplanet.Types) `Vote.Verify()` has been removed. [[#3837]]

### Backward-incompatible API changes

Expand Down Expand Up @@ -63,6 +64,7 @@ To be released.
### CLI tools

[#3811]: https://github.com/planetarium/libplanet/pull/3811
[#3837]: https://github.com/planetarium/libplanet/pull/3837


Version 4.6.1
Expand Down
9 changes: 2 additions & 7 deletions Libplanet.Net/Consensus/HeightVoteSet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -120,11 +120,6 @@ public void AddVote(Vote vote)

PublicKey validatorKey = vote.ValidatorPublicKey;

if (validatorKey is null)
{
throw new InvalidVoteException("ValidatorKey of the vote cannot be null", vote);
}

if (!_validatorSet.ContainsPublicKey(validatorKey))
{
throw new InvalidVoteException(
Expand All @@ -140,10 +135,10 @@ public void AddVote(Vote vote)
vote);
}

if (!vote.Verify())
if (vote.Signature.IsEmpty)
{
throw new InvalidVoteException(
"Received vote's signature is invalid",
"Received vote's signature is empty",
vote);
}

Expand Down
13 changes: 0 additions & 13 deletions Libplanet.Types/Consensus/Vote.cs
Original file line number Diff line number Diff line change
Expand Up @@ -117,19 +117,6 @@ private Vote(Bencodex.Types.Dictionary encoded)
? ((Bencodex.Types.Dictionary)_metadata.Bencoded).Add(SignatureKey, Signature)
: _metadata.Bencoded;

/// <summary>
/// Verifies whether the <see cref="Vote"/>'s payload is properly signed by
/// <see cref="Validator"/>.
/// </summary>
/// <returns><see langword="true"/> if the <see cref="Signature"/> is not empty
/// and is a valid signature signed by <see cref="Validator"/>,
/// <see langword="false"/> otherwise.</returns>
[Pure]
public bool Verify() =>
!Signature.IsEmpty &&
ValidatorPublicKey.Verify(
_codec.Encode(_metadata.Bencoded).ToImmutableArray(), Signature);

/// <inheritdoc/>
[Pure]
public bool Equals(Vote? other)
Expand Down

0 comments on commit f13ade5

Please sign in to comment.