Skip to content

Commit

Permalink
Merge pull request #2420 from Taraxa-project/missing_tip_fix
Browse files Browse the repository at this point in the history
fix: dag missing tip
  • Loading branch information
MatusKysel authored Mar 28, 2023
2 parents 5777eab + ace58d2 commit f30d4f1
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
3 changes: 2 additions & 1 deletion libraries/core_libs/consensus/include/dag/dag_manager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ class DagManager : public std::enable_shared_from_this<DagManager> {
ExpiredBlock,
IncorrectTransactionsEstimation,
BlockTooBig,
FailedTipsVerification
FailedTipsVerification,
MissingTip
};

explicit DagManager(const DagBlock &dag_genesis_block, addr_t node_addr, const SortitionConfig &sortition_config,
Expand Down
3 changes: 2 additions & 1 deletion libraries/core_libs/consensus/src/dag/dag_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -675,7 +675,8 @@ DagManager::VerifyBlockReturnType DagManager::verifyBlock(const DagBlock &blk) {
if ((blk.getTips().size() + 1) > kPbftGasLimit / getDagConfig().gas_limit) {
for (const auto &t : blk.getTips()) {
const auto tip_blk = getDagBlock(t);
assert(tip_blk);
LOG(log_er_) << "DAG Block " << block_hash << " tip " << t << " not present";
if (tip_blk == nullptr) return VerifyBlockReturnType::MissingTip;
block_gas_estimation += tip_blk->getGasEstimation();
}
if (block_gas_estimation > kPbftGasLimit) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,16 @@ void DagBlockPacketHandler::onNewBlockReceived(DagBlock &&block, const std::shar
}
}
break;
case DagManager::VerifyBlockReturnType::MissingTip:
if (peer->peer_dag_synced_) {
std::ostringstream err_msg;
err_msg << "DagBlock has missing tip";
throw MaliciousPeerException(err_msg.str());
} else {
// peer_dag_synced_ flag ensures that this can only be performed once for a peer
requestPendingDagBlocks(peer);
}
break;
case DagManager::VerifyBlockReturnType::AheadBlock:
case DagManager::VerifyBlockReturnType::FutureBlock:
if (peer->peer_dag_synced_) {
Expand Down

0 comments on commit f30d4f1

Please sign in to comment.