Skip to content

Commit

Permalink
fix view-change failed for failure to verify proposal dure to consens…
Browse files Browse the repository at this point in the history
…us node list modification (FISCO-BCOS#2191)

* update log-level for pbft

* fix view-change failed for failure to verify proposal dure to consensus node list modification
  • Loading branch information
cyjseagull authored Feb 24, 2022
1 parent 68b8c8c commit 955b3cb
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 6 deletions.
23 changes: 22 additions & 1 deletion bcos-pbft/bcos-pbft/pbft/cache/PBFTCacheProcessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -687,7 +687,28 @@ bool PBFTCacheProcessor::checkPrecommitMsg(PBFTMessageInterface::Ptr _precommitM
{
return false;
}
return checkPrecommitWeight(_precommitMsg);
auto ret = checkPrecommitWeight(_precommitMsg);
if (ret == true)
{
return ret;
}
// avoid the failure to verify proposalWeight due to the modification of consensus node list and
// consensus weight
if (!m_caches.count(_precommitMsg->index()))
{
return ret;
}
auto precommit = (m_caches.at(_precommitMsg->index()))->preCommitCache();
if (!precommit)
{
return ret;
}
// erase the cache
if (precommit->hash() == _precommitMsg->hash())
{
m_caches.erase(precommit->index());
}
return ret;
}

bool PBFTCacheProcessor::checkPrecommitWeight(PBFTMessageInterface::Ptr _precommitMsg)
Expand Down
11 changes: 6 additions & 5 deletions bcos-pbft/bcos-pbft/pbft/engine/PBFTEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -468,11 +468,11 @@ void PBFTEngine::executeWorker()
// proposal
if ((c_consensusPacket.count(packetType)) && !m_config->canHandleNewProposal(pbftMsg))
{
PBFT_LOG(INFO) << LOG_DESC(
"receive consensus packet, re-push it to the msgQueue for "
"canHandleNewProposal")
<< LOG_KV("index", pbftMsg->index()) << LOG_KV("type", packetType)
<< m_config->printCurrentState();
PBFT_LOG(TRACE) << LOG_DESC(
"receive consensus packet, re-push it to the msgQueue for "
"canHandleNewProposal")
<< LOG_KV("index", pbftMsg->index()) << LOG_KV("type", packetType)
<< m_config->printCurrentState();
m_msgQueue->push(pbftMsg);
if (empty)
{
Expand Down Expand Up @@ -1044,6 +1044,7 @@ bool PBFTEngine::isValidViewChangeMsg(bcos::crypto::NodeIDPtr _fromNode,
if (!m_cacheProcessor->checkPrecommitMsg(precommitMsg))
{
PBFT_LOG(INFO) << LOG_DESC("InvalidViewChangeReq for invalid proposal")
<< LOG_KV("viewChangeFrom", _viewChangeMsg->generatedFrom())
<< printPBFTMsgInfo(precommitMsg) << m_config->printCurrentState();
return false;
}
Expand Down

0 comments on commit 955b3cb

Please sign in to comment.