Skip to content

Commit

Permalink
chore: check for double PBFT votes in proposed blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
MatusKysel committed Mar 20, 2023
1 parent 14dcbd9 commit d5cc15b
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -162,12 +162,15 @@ bool ExtVotesPacketHandler::validateVoteAndBlock(const std::shared_ptr<Vote> &vo
<< pbft_block->getBlockHash();
return false;
}
// TODO[2401]: move this check to PBFT block
std::unordered_set<vote_hash_t> 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;
}
}

Expand Down

0 comments on commit d5cc15b

Please sign in to comment.