Skip to content

Commit

Permalink
chore: introduce check on double votes
Browse files Browse the repository at this point in the history
  • Loading branch information
MatusKysel committed Mar 17, 2023
1 parent 1500374 commit 9a2b67f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ std::optional<addr_t> RewardsStats::getTransactionValidator(const trx_hash_t& tx
bool RewardsStats::addVote(const std::shared_ptr<Vote>& vote) {
// Set valid cert vote to validator
auto& validator_stats = validators_stats_[vote->getVoterAddr()];
assert(validator_stats.vote_weight_ == 0);
// assert(validator_stats.vote_weight_ == 0);
assert(vote->getWeight());

if (validator_stats.vote_weight_) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,14 @@ bool ExtVotesPacketHandler::validateVoteAndBlock(const std::shared_ptr<Vote> &vo
<< pbft_block->getBlockHash();
return false;
}
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;
}
}

return true;
}
Expand Down

0 comments on commit 9a2b67f

Please sign in to comment.