From 8ba3efdc40da201a551fb370c56369d8fec6547a Mon Sep 17 00:00:00 2001 From: Matus Kysel Date: Fri, 17 Mar 2023 09:15:01 +0100 Subject: [PATCH] chore: just fix to make testnet runing --- .../consensus/src/final_chain/rewards_stats.cpp | 2 +- .../common/ext_votes_packet_handler.cpp | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/libraries/core_libs/consensus/src/final_chain/rewards_stats.cpp b/libraries/core_libs/consensus/src/final_chain/rewards_stats.cpp index 809a48d227..f14bbb0d11 100644 --- a/libraries/core_libs/consensus/src/final_chain/rewards_stats.cpp +++ b/libraries/core_libs/consensus/src/final_chain/rewards_stats.cpp @@ -30,7 +30,7 @@ std::optional RewardsStats::getTransactionValidator(const trx_hash_t& tx bool RewardsStats::addVote(const std::shared_ptr& 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_) { 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 cc5fd3e42a..f4c3d4093b 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 @@ -103,7 +103,7 @@ std::pair ExtVotesPacketHandler::validateVotePeriodRoundStep( checking_round = 1; } - // vote->getRound() == checking_round - 1 && next_vote -> previous round next vote + // vote->gtRound() == checking_round - 1 && next_vote -> previous round next vote if (vote->getRound() < checking_round - 1 || (vote->getRound() == checking_round - 1 && vote->getType() != PbftVoteTypes::next_vote)) { return {false, "Invalid round(too small): " + genErrMsg(vote)}; @@ -162,6 +162,14 @@ bool ExtVotesPacketHandler::validateVoteAndBlock(const std::shared_ptr &vo << pbft_block->getBlockHash(); return false; } + 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; + } + } return true; }