Skip to content

Commit fda16f1

Browse files
authored
Fix off-by-1 in phase calculations and the rest of llmq-signing.py issues (#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
1 parent b595f9e commit fda16f1

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

qa/rpc-tests/test_framework/test_framework.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,7 @@ def check_sporks_same(self):
391391
return False
392392
return True
393393

394-
def wait_for_quorum_phase(self, phase, check_received_messages, check_received_messages_count, timeout=5):
394+
def wait_for_quorum_phase(self, phase, check_received_messages, check_received_messages_count, timeout=15):
395395
t = time()
396396
while time() - t < timeout:
397397
all_ok = True
@@ -404,15 +404,15 @@ def wait_for_quorum_phase(self, phase, check_received_messages, check_received_m
404404
all_ok = False
405405
break
406406
if check_received_messages is not None:
407-
if s["receivedContributions"] < check_received_messages_count:
407+
if s[check_received_messages] < check_received_messages_count:
408408
all_ok = False
409409
break
410410
if all_ok:
411411
return
412412
sleep(0.1)
413413
raise AssertionError("wait_for_quorum_phase timed out")
414414

415-
def wait_for_quorum_commitment(self, timeout = 5):
415+
def wait_for_quorum_commitment(self, timeout = 15):
416416
t = time()
417417
while time() - t < timeout:
418418
all_ok = True
@@ -449,7 +449,7 @@ def mine_quorum(self, expected_valid_count=10):
449449
self.nodes[0].generate(2)
450450

451451
# Make sure all reached phase 3 (complain) and received all complaints
452-
self.wait_for_quorum_phase(3, "receivedComplaints" if expected_valid_count != 0 else None, expected_valid_count)
452+
self.wait_for_quorum_phase(3, "receivedComplaints" if expected_valid_count != 10 else None, expected_valid_count)
453453
set_mocktime(get_mocktime() + 1)
454454
set_node_times(self.nodes, get_mocktime())
455455
self.nodes[0].generate(2)

src/llmq/quorums_dkgsessionhandler.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ void CDKGSessionHandler::UpdatedBlockTip(const CBlockIndex* pindexNew, const CBl
121121
quorumHash = pindexQuorum->GetBlockHash();
122122

123123
bool fNewPhase = (quorumStageInt % params.dkgPhaseBlocks) == 0;
124-
int phaseInt = quorumStageInt / params.dkgPhaseBlocks;
124+
int phaseInt = quorumStageInt / params.dkgPhaseBlocks + 1;
125125
if (fNewPhase && phaseInt >= QuorumPhase_Initialized && phaseInt <= QuorumPhase_Idle) {
126126
phase = static_cast<QuorumPhase>(phaseInt);
127127
if (phase == QuorumPhase_Initialized) {

src/llmq/quorums_dkgsessionhandler.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ namespace llmq
1616

1717
enum QuorumPhase {
1818
QuorumPhase_None = -1,
19-
QuorumPhase_Initialized,
19+
QuorumPhase_Initialized = 1,
2020
QuorumPhase_Contribute,
2121
QuorumPhase_Complain,
2222
QuorumPhase_Justify,

0 commit comments

Comments
 (0)