Skip to content

Commit

Permalink
fix pillar votes syncing
Browse files Browse the repository at this point in the history
  • Loading branch information
JakubFornadel committed Jun 5, 2024
1 parent dade248 commit 385b71a
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ PillarChainManager::PillarChainManager(const FicusHardforkConfig& ficus_hf_confi

if (auto&& latest_pillar_block_data = db_->getLatestPillarBlockData(); latest_pillar_block_data.has_value()) {
last_finalized_pillar_block_ = std::move(latest_pillar_block_data->block_);
for (const auto& vote : latest_pillar_block_data->pillar_votes_) {
addVerifiedPillarVote(vote);
}
}

LOG_OBJECTS_CREATE("PILLAR_CHAIN");
Expand Down Expand Up @@ -294,7 +297,12 @@ bool PillarChainManager::isRelevantPillarVote(const std::shared_ptr<PillarVote>
return false;
}

return !pillar_votes_.voteExists(vote);
if (pillar_votes_.voteExists(vote)) {
LOG(log_dg_) << "Received vote " << vote->getHash() << " already saved";
return false;
}

return true;
}

bool PillarChainManager::validatePillarVote(const std::shared_ptr<PillarVote> vote) const {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ void GetPillarVotesBundlePacketHandler::validatePacketRlpFormat(const threadpool

void GetPillarVotesBundlePacketHandler::process(const threadpool::PacketData &packet_data,
const std::shared_ptr<TaraxaPeer> &peer) {
LOG(log_dg_) << "GetPillarVotesBundlePacketHandler received from peer " << peer->getId();
const PbftPeriod period = packet_data.rlp_[0].toInt();
const blk_hash_t pillar_block_hash = packet_data.rlp_[1].toHash<blk_hash_t>();

Expand Down Expand Up @@ -58,13 +59,17 @@ void GetPillarVotesBundlePacketHandler::process(const threadpool::PacketData &pa

void GetPillarVotesBundlePacketHandler::requestPillarVotesBundle(PbftPeriod period, const blk_hash_t &pillar_block_hash,
const std::shared_ptr<TaraxaPeer> &peer) {
dev::RLPStream s(2);
dev::RLPStream s(kGetPillarVotesBundlePacketSize);
s << period;
s << pillar_block_hash;

sealAndSend(peer->getId(), SubprotocolPacketType::GetPillarVotesBundlePacket, std::move(s));
LOG(log_nf_) << "Requested pillar votes bundle for period " << period << " and pillar block " << pillar_block_hash
<< " from peer " << peer->getId();
if (sealAndSend(peer->getId(), SubprotocolPacketType::GetPillarVotesBundlePacket, std::move(s))) {
LOG(log_nf_) << "Requested pillar votes bundle for period " << period << " and pillar block " << pillar_block_hash
<< " from peer " << peer->getId();
} else {
LOG(log_er_) << "Unable to send pillar votes bundle request for period " << period << " and pillar block "
<< pillar_block_hash << " to peer " << peer->getId();
}
}

} // namespace taraxa::network::tarcap
2 changes: 2 additions & 0 deletions libraries/core_libs/network/src/threadpool/priority_queue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,8 @@ void PriorityQueue::updateDependenciesFinish(const PacketData& packet, std::mute
switch (packet.type_) {
case SubprotocolPacketType::GetDagSyncPacket:
case SubprotocolPacketType::GetPbftSyncPacket:
case SubprotocolPacketType::GetPillarVotesBundlePacket:
case SubprotocolPacketType::PillarVotesBundlePacket: // TODO[2744]: remove
case SubprotocolPacketType::PbftSyncPacket: {
std::unique_lock<std::mutex> lock(queue_mutex);
blocked_packets_mask_.markPacketAsHardUnblocked(packet, packet.type_);
Expand Down

0 comments on commit 385b71a

Please sign in to comment.