Skip to content

Commit

Permalink
Fix LLMQ related test failures on Travis (#2666)
Browse files Browse the repository at this point in the history
* 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.
  • Loading branch information
codablock committed Jan 30, 2019
1 parent 6fe479a commit 54f576e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
2 changes: 1 addition & 1 deletion qa/rpc-tests/llmq-chainlocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

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):

Expand Down
19 changes: 10 additions & 9 deletions src/llmq/quorums_dkgsessionhandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,21 +123,13 @@ 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<QuorumPhase>(phaseInt);
if (phase == QuorumPhase_Initialized) {
quorumDKGDebugManager->ResetLocalSessionStatus(params.type, quorumHash, quorumHeight);
}
}

quorumDKGDebugManager->UpdateLocalStatus([&](CDKGDebugStatus& status) {
bool changed = status.nHeight != pindexNew->nHeight;
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)
Expand Down Expand Up @@ -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();
Expand All @@ -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)
Expand Down

0 comments on commit 54f576e

Please sign in to comment.