Skip to content

Commit

Permalink
fix: do not broadcast votes that were not processed + request pbft sy…
Browse files Browse the repository at this point in the history
…ncing only vote sender is also vote author
  • Loading branch information
JakubFornadel committed Mar 16, 2023
1 parent 341a0c2 commit 35ffa41
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,8 @@ std::pair<bool, std::string> ExtVotesPacketHandler::validateVotePeriodRoundStep(
// skip this check if kConf.network.ddos_protection.vote_accepting_periods == 0
// vote->getPeriod() - 1 is here because votes are validated against vote_period - 1 in dpos contract
// Do not request round sync too often here
if (std::chrono::system_clock::now() - last_pbft_block_sync_request_time_ > kSyncRequestInterval) {
if (vote->getVoter() == peer->getId() &&
std::chrono::system_clock::now() - last_pbft_block_sync_request_time_ > kSyncRequestInterval) {
// request PBFT chain sync from this node
sealAndSend(peer->getId(), SubprotocolPacketType::GetPbftSyncPacket,
std::move(dev::RLPStream(1) << std::max(vote->getPeriod() - 1, peer->pbft_chain_size_.load())));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,9 @@ void VotePacketHandler::process(const PacketData &packet_data, const std::shared
peer->markPbftBlockAsKnown(pbft_block->getBlockHash());
}

processVote(vote, pbft_block, peer, true);
if (processVote(vote, pbft_block, peer, true)) {
return;
}

// Do not mark it before, as peers have small caches of known votes. Only mark gossiping votes
peer->markVoteAsKnown(vote_hash);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,10 @@ 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;
processVote(vote, nullptr, peer, check_max_round_step);
if (processVote(vote, nullptr, peer, check_max_round_step)) {
continue;
}

votes.push_back(std::move(vote));
}

Expand Down

0 comments on commit 35ffa41

Please sign in to comment.