From f9cbfdb5e81d736607ece154d323fea9fce60958 Mon Sep 17 00:00:00 2001 From: JakubFornadel Date: Mon, 20 Mar 2023 12:15:21 +0100 Subject: [PATCH] fix processVote return value check --- .../packets_handlers/common/ext_votes_packet_handler.cpp | 2 +- .../src/tarcap/packets_handlers/vote_packet_handler.cpp | 2 +- .../tarcap/packets_handlers/votes_sync_packet_handler.cpp | 8 ++++++-- 3 files changed, 8 insertions(+), 4 deletions(-) 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 759a0752e5..4a8e9f67b9 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 @@ -30,7 +30,7 @@ bool ExtVotesPacketHandler::processVote(const std::shared_ptr &vote, const return false; } - // Validate vote's period, roun and step min/max values + // Validate vote's period, round and step min/max values if (const auto vote_valid = validateVotePeriodRoundStep(vote, peer, validate_max_round_step); !vote_valid.first) { LOG(log_wr_) << "Vote period/round/step " << vote->getHash() << " validation failed. Err: " << vote_valid.second; return false; diff --git a/libraries/core_libs/network/src/tarcap/packets_handlers/vote_packet_handler.cpp b/libraries/core_libs/network/src/tarcap/packets_handlers/vote_packet_handler.cpp index dd213a4e63..7c4f3aa6cd 100644 --- a/libraries/core_libs/network/src/tarcap/packets_handlers/vote_packet_handler.cpp +++ b/libraries/core_libs/network/src/tarcap/packets_handlers/vote_packet_handler.cpp @@ -63,7 +63,7 @@ void VotePacketHandler::process(const PacketData &packet_data, const std::shared peer->markPbftBlockAsKnown(pbft_block->getBlockHash()); } - if (processVote(vote, pbft_block, peer, true)) { + if (!processVote(vote, pbft_block, peer, true)) { return; } diff --git a/libraries/core_libs/network/src/tarcap/packets_handlers/votes_sync_packet_handler.cpp b/libraries/core_libs/network/src/tarcap/packets_handlers/votes_sync_packet_handler.cpp index 02124ebbb2..74f4b2e30a 100644 --- a/libraries/core_libs/network/src/tarcap/packets_handlers/votes_sync_packet_handler.cpp +++ b/libraries/core_libs/network/src/tarcap/packets_handlers/votes_sync_packet_handler.cpp @@ -113,8 +113,12 @@ void VotesSyncPacketHandler::process(const PacketData &packet_data, const std::s // Process processStandardVote is called with false in case of next votes bundle -> does not check max boundaries // for round and step to actually being able to sync the current round in case network is stalled - bool check_max_round_step = votes_bundle_votes_type == PbftVoteTypes::next_vote ? false : true; - if (processVote(vote, nullptr, peer, check_max_round_step)) { + bool check_max_round_step = true; + if (votes_bundle_votes_type == PbftVoteTypes::cert_vote || votes_bundle_votes_type == PbftVoteTypes::next_vote) { + check_max_round_step = false; + } + + if (!processVote(vote, nullptr, peer, check_max_round_step)) { continue; }