From 54f576ea7c2aee595fb7eb0a120ca3f4966c7ea5 Mon Sep 17 00:00:00 2001 From: Alexander Block Date: Wed, 30 Jan 2019 14:05:22 +0100 Subject: [PATCH] Fix LLMQ related test failures on Travis (#2666) * Use fast_dip3_enforcement instead of fast_dip3_activation DashTestFramework was refactored before ChainLocks got merged, causing tests to fail now. * Move updating of DKG debug status into WaitForNextPhase Otherwise callers of the RPCs might believe that the next phase has already started and start producing more blocks, which would then cancel the current session if it happens faster than the phase handler thread can progress to the next phase. --- qa/rpc-tests/llmq-chainlocks.py | 2 +- src/llmq/quorums_dkgsessionhandler.cpp | 19 ++++++++++--------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/qa/rpc-tests/llmq-chainlocks.py b/qa/rpc-tests/llmq-chainlocks.py index 0980febd9c..cdb76ad74a 100755 --- a/qa/rpc-tests/llmq-chainlocks.py +++ b/qa/rpc-tests/llmq-chainlocks.py @@ -17,7 +17,7 @@ Checks LLMQs based ChainLocks class LLMQChainLocksTest(DashTestFramework): def __init__(self): - super().__init__(11, 10, [], fast_dip3_activation=True) + super().__init__(11, 10, [], fast_dip3_enforcement=True) def run_test(self): diff --git a/src/llmq/quorums_dkgsessionhandler.cpp b/src/llmq/quorums_dkgsessionhandler.cpp index e7220127c9..f2cf23c707 100644 --- a/src/llmq/quorums_dkgsessionhandler.cpp +++ b/src/llmq/quorums_dkgsessionhandler.cpp @@ -123,9 +123,6 @@ void CDKGSessionHandler::UpdatedBlockTip(const CBlockIndex* pindexNew, const CBl int phaseInt = quorumStageInt / params.dkgPhaseBlocks + 1; if (fNewPhase && phaseInt >= QuorumPhase_Initialized && phaseInt <= QuorumPhase_Idle) { phase = static_cast(phaseInt); - if (phase == QuorumPhase_Initialized) { - quorumDKGDebugManager->ResetLocalSessionStatus(params.type, quorumHash, quorumHeight); - } } quorumDKGDebugManager->UpdateLocalStatus([&](CDKGDebugStatus& status) { @@ -133,11 +130,6 @@ void CDKGSessionHandler::UpdatedBlockTip(const CBlockIndex* pindexNew, const CBl status.nHeight = (uint32_t)pindexNew->nHeight; return changed; }); - quorumDKGDebugManager->UpdateLocalSessionStatus(params.type, [&](CDKGDebugSessionStatus& status) { - bool changed = status.phase != (uint8_t)phase; - status.phase = (uint8_t)phase; - return changed; - }); } void CDKGSessionHandler::ProcessMessage(CNode* pfrom, const std::string& strCommand, CDataStream& vRecv, CConnman& connman) @@ -199,7 +191,7 @@ void CDKGSessionHandler::WaitForNextPhase(QuorumPhase curPhase, throw AbortPhaseException(); } if (p.first == nextPhase) { - return; + break; } if (curPhase != QuorumPhase_None && p.first != curPhase) { throw AbortPhaseException(); @@ -208,6 +200,15 @@ void CDKGSessionHandler::WaitForNextPhase(QuorumPhase curPhase, MilliSleep(100); } } + + if (nextPhase == QuorumPhase_Initialized) { + quorumDKGDebugManager->ResetLocalSessionStatus(params.type, quorumHash, quorumHeight); + } + quorumDKGDebugManager->UpdateLocalSessionStatus(params.type, [&](CDKGDebugSessionStatus& status) { + bool changed = status.phase != (uint8_t)nextPhase; + status.phase = (uint8_t)nextPhase; + return changed; + }); } void CDKGSessionHandler::WaitForNewQuorum(const uint256& oldQuorumHash)