From f13ade5eaf30eded0e5146022daa753408690d0e Mon Sep 17 00:00:00 2001 From: ilgyu Date: Thu, 20 Jun 2024 15:49:14 +0900 Subject: [PATCH] feat: Remove Vote.Verify() --- CHANGES.md | 2 ++ Libplanet.Net/Consensus/HeightVoteSet.cs | 9 ++------- Libplanet.Types/Consensus/Vote.cs | 13 ------------- 3 files changed, 4 insertions(+), 20 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index b388556b42..40a74cd5ab 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -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 @@ -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 diff --git a/Libplanet.Net/Consensus/HeightVoteSet.cs b/Libplanet.Net/Consensus/HeightVoteSet.cs index 32cb11936a..8fc82c94e8 100644 --- a/Libplanet.Net/Consensus/HeightVoteSet.cs +++ b/Libplanet.Net/Consensus/HeightVoteSet.cs @@ -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( @@ -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); } diff --git a/Libplanet.Types/Consensus/Vote.cs b/Libplanet.Types/Consensus/Vote.cs index e49b31c2f3..54c166f5ac 100644 --- a/Libplanet.Types/Consensus/Vote.cs +++ b/Libplanet.Types/Consensus/Vote.cs @@ -117,19 +117,6 @@ private Vote(Bencodex.Types.Dictionary encoded) ? ((Bencodex.Types.Dictionary)_metadata.Bencoded).Add(SignatureKey, Signature) : _metadata.Bencoded; - /// - /// Verifies whether the 's payload is properly signed by - /// . - /// - /// if the is not empty - /// and is a valid signature signed by , - /// otherwise. - [Pure] - public bool Verify() => - !Signature.IsEmpty && - ValidatorPublicKey.Verify( - _codec.Encode(_metadata.Bencoded).ToImmutableArray(), Signature); - /// [Pure] public bool Equals(Vote? other)