Skip to content

Commit

Permalink
Fix off-by-1 in phase calculations and the rest of llmq-signing.py is…
Browse files Browse the repository at this point in the history
…sues (#2641)

* Fix off-by-1 in phase calculations

* Fix wait_for_quorum_phase, should look for check_received_messages

* Fix wait_for_quorum_phase for complain phase

* Bump default timeout in wait_for_quorum_phase/wait_for_quorum_commitment to 15
  • Loading branch information
UdjinM6 committed Jan 23, 2019
1 parent b595f9e commit fda16f1
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions qa/rpc-tests/test_framework/test_framework.py
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ def check_sporks_same(self):
return False
return True

def wait_for_quorum_phase(self, phase, check_received_messages, check_received_messages_count, timeout=5):
def wait_for_quorum_phase(self, phase, check_received_messages, check_received_messages_count, timeout=15):
t = time()
while time() - t < timeout:
all_ok = True
Expand All @@ -404,15 +404,15 @@ def wait_for_quorum_phase(self, phase, check_received_messages, check_received_m
all_ok = False
break
if check_received_messages is not None:
if s["receivedContributions"] < check_received_messages_count:
if s[check_received_messages] < check_received_messages_count:
all_ok = False
break
if all_ok:
return
sleep(0.1)
raise AssertionError("wait_for_quorum_phase timed out")

def wait_for_quorum_commitment(self, timeout = 5):
def wait_for_quorum_commitment(self, timeout = 15):
t = time()
while time() - t < timeout:
all_ok = True
Expand Down Expand Up @@ -449,7 +449,7 @@ def mine_quorum(self, expected_valid_count=10):
self.nodes[0].generate(2)

# Make sure all reached phase 3 (complain) and received all complaints
self.wait_for_quorum_phase(3, "receivedComplaints" if expected_valid_count != 0 else None, expected_valid_count)
self.wait_for_quorum_phase(3, "receivedComplaints" if expected_valid_count != 10 else None, expected_valid_count)
set_mocktime(get_mocktime() + 1)
set_node_times(self.nodes, get_mocktime())
self.nodes[0].generate(2)
Expand Down
2 changes: 1 addition & 1 deletion src/llmq/quorums_dkgsessionhandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ void CDKGSessionHandler::UpdatedBlockTip(const CBlockIndex* pindexNew, const CBl
quorumHash = pindexQuorum->GetBlockHash();

bool fNewPhase = (quorumStageInt % params.dkgPhaseBlocks) == 0;
int phaseInt = quorumStageInt / params.dkgPhaseBlocks;
int phaseInt = quorumStageInt / params.dkgPhaseBlocks + 1;
if (fNewPhase && phaseInt >= QuorumPhase_Initialized && phaseInt <= QuorumPhase_Idle) {
phase = static_cast<QuorumPhase>(phaseInt);
if (phase == QuorumPhase_Initialized) {
Expand Down
2 changes: 1 addition & 1 deletion src/llmq/quorums_dkgsessionhandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ namespace llmq

enum QuorumPhase {
QuorumPhase_None = -1,
QuorumPhase_Initialized,
QuorumPhase_Initialized = 1,
QuorumPhase_Contribute,
QuorumPhase_Complain,
QuorumPhase_Justify,
Expand Down

0 comments on commit fda16f1

Please sign in to comment.