From d5cc15bb66d4c4822ed039c5a541a128545c86ab Mon Sep 17 00:00:00 2001 From: Matus Kysel Date: Mon, 20 Mar 2023 16:18:57 +0100 Subject: [PATCH] chore: check for double PBFT votes in proposed blocks --- .../packets_handlers/common/ext_votes_packet_handler.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libraries/core_libs/network/src/tarcap/packets_handlers/common/ext_votes_packet_handler.cpp b/libraries/core_libs/network/src/tarcap/packets_handlers/common/ext_votes_packet_handler.cpp index d11d3c4daf..5ddd8bacab 100644 --- a/libraries/core_libs/network/src/tarcap/packets_handlers/common/ext_votes_packet_handler.cpp +++ b/libraries/core_libs/network/src/tarcap/packets_handlers/common/ext_votes_packet_handler.cpp @@ -162,12 +162,15 @@ bool ExtVotesPacketHandler::validateVoteAndBlock(const std::shared_ptr &vo << pbft_block->getBlockHash(); return false; } + // TODO[2401]: move this check to PBFT block std::unordered_set set; const auto reward_votes = pbft_block->getRewardVotes(); set.reserve(reward_votes.size()); for (const auto &hash : reward_votes) { if (!set.insert(hash).second) { - LOG(log_er_) << "PBFT block " << pbft_block->getBlockHash() << " has duplicated vote " << hash; + LOG(log_er_) << "PBFT block " << pbft_block->getBlockHash() << " proposed by " << pbft_block->getBeneficiary() + << " has duplicated vote " << hash; + return false; } }