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
This commit is contained in:
parent
b595f9e6a1
commit
fda16f1fea
@ -391,7 +391,7 @@ class DashTestFramework(BitcoinTestFramework):
|
|||||||
return False
|
return False
|
||||||
return True
|
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()
|
t = time()
|
||||||
while time() - t < timeout:
|
while time() - t < timeout:
|
||||||
all_ok = True
|
all_ok = True
|
||||||
@ -404,7 +404,7 @@ class DashTestFramework(BitcoinTestFramework):
|
|||||||
all_ok = False
|
all_ok = False
|
||||||
break
|
break
|
||||||
if check_received_messages is not None:
|
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
|
all_ok = False
|
||||||
break
|
break
|
||||||
if all_ok:
|
if all_ok:
|
||||||
@ -412,7 +412,7 @@ class DashTestFramework(BitcoinTestFramework):
|
|||||||
sleep(0.1)
|
sleep(0.1)
|
||||||
raise AssertionError("wait_for_quorum_phase timed out")
|
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()
|
t = time()
|
||||||
while time() - t < timeout:
|
while time() - t < timeout:
|
||||||
all_ok = True
|
all_ok = True
|
||||||
@ -449,7 +449,7 @@ class DashTestFramework(BitcoinTestFramework):
|
|||||||
self.nodes[0].generate(2)
|
self.nodes[0].generate(2)
|
||||||
|
|
||||||
# Make sure all reached phase 3 (complain) and received all complaints
|
# 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_mocktime(get_mocktime() + 1)
|
||||||
set_node_times(self.nodes, get_mocktime())
|
set_node_times(self.nodes, get_mocktime())
|
||||||
self.nodes[0].generate(2)
|
self.nodes[0].generate(2)
|
||||||
|
@ -121,7 +121,7 @@ void CDKGSessionHandler::UpdatedBlockTip(const CBlockIndex* pindexNew, const CBl
|
|||||||
quorumHash = pindexQuorum->GetBlockHash();
|
quorumHash = pindexQuorum->GetBlockHash();
|
||||||
|
|
||||||
bool fNewPhase = (quorumStageInt % params.dkgPhaseBlocks) == 0;
|
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) {
|
if (fNewPhase && phaseInt >= QuorumPhase_Initialized && phaseInt <= QuorumPhase_Idle) {
|
||||||
phase = static_cast<QuorumPhase>(phaseInt);
|
phase = static_cast<QuorumPhase>(phaseInt);
|
||||||
if (phase == QuorumPhase_Initialized) {
|
if (phase == QuorumPhase_Initialized) {
|
||||||
|
@ -16,7 +16,7 @@ namespace llmq
|
|||||||
|
|
||||||
enum QuorumPhase {
|
enum QuorumPhase {
|
||||||
QuorumPhase_None = -1,
|
QuorumPhase_None = -1,
|
||||||
QuorumPhase_Initialized,
|
QuorumPhase_Initialized = 1,
|
||||||
QuorumPhase_Contribute,
|
QuorumPhase_Contribute,
|
||||||
QuorumPhase_Complain,
|
QuorumPhase_Complain,
|
||||||
QuorumPhase_Justify,
|
QuorumPhase_Justify,
|
||||||
|
Loading…
Reference in New Issue
Block a user