Skip to content

Commit

Permalink
Multiple fixes for LLMQs and BLS batch verification (#2674)
Browse files Browse the repository at this point in the history
* Check aggPubKey for IsValid() instead of aggSig

aggSig is not reliable here as it might already be initialized by the
previous message.

* Significantly reduce sleep time for each DKG phase

Turns out the DKG is much faster then expected, and waiting multiple
minutes for each phase in a devnet is not much fun.

* Correctly use SIGN_HEIGHT_OFFSET when checking for out of bound height

* Introduce startBlockHeight to make things more explicit
  • Loading branch information
codablock authored and UdjinM6 committed Feb 1, 2019
1 parent ae70e8a commit 088525b
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/bls/bls_batchverifier.h
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ class CBLSInsecureBatchVerifier
}
}

if (!aggSig.IsValid()) {
if (!aggPubKey.IsValid()) {
// only duplicates for this msgHash
continue;
}
Expand Down
8 changes: 4 additions & 4 deletions src/llmq/quorums_dkgsessionhandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,7 @@ void CDKGSessionHandler::HandleDKGRound()
auto fContributeWait = [this] {
return ProcessPendingMessageBatch<CDKGContribution>(*curSession, pendingContributions, 8);
};
HandlePhase(QuorumPhase_Contribute, QuorumPhase_Complain, curQuorumHash, 0.5, fContributeStart, fContributeWait);
HandlePhase(QuorumPhase_Contribute, QuorumPhase_Complain, curQuorumHash, 0.05, fContributeStart, fContributeWait);

// Complain
auto fComplainStart = [this]() {
Expand All @@ -518,7 +518,7 @@ void CDKGSessionHandler::HandleDKGRound()
auto fComplainWait = [this] {
return ProcessPendingMessageBatch<CDKGComplaint>(*curSession, pendingComplaints, 8);
};
HandlePhase(QuorumPhase_Complain, QuorumPhase_Justify, curQuorumHash, 0.1, fComplainStart, fComplainWait);
HandlePhase(QuorumPhase_Complain, QuorumPhase_Justify, curQuorumHash, 0.05, fComplainStart, fComplainWait);

// Justify
auto fJustifyStart = [this]() {
Expand All @@ -527,7 +527,7 @@ void CDKGSessionHandler::HandleDKGRound()
auto fJustifyWait = [this] {
return ProcessPendingMessageBatch<CDKGJustification>(*curSession, pendingJustifications, 8);
};
HandlePhase(QuorumPhase_Justify, QuorumPhase_Commit, curQuorumHash, 0.1, fJustifyStart, fJustifyWait);
HandlePhase(QuorumPhase_Justify, QuorumPhase_Commit, curQuorumHash, 0.05, fJustifyStart, fJustifyWait);

// Commit
auto fCommitStart = [this]() {
Expand All @@ -536,7 +536,7 @@ void CDKGSessionHandler::HandleDKGRound()
auto fCommitWait = [this] {
return ProcessPendingMessageBatch<CDKGPrematureCommitment>(*curSession, pendingPrematureCommitments, 8);
};
HandlePhase(QuorumPhase_Commit, QuorumPhase_Finalize, curQuorumHash, 0.5, fCommitStart, fCommitWait);
HandlePhase(QuorumPhase_Commit, QuorumPhase_Finalize, curQuorumHash, 0.1, fCommitStart, fCommitWait);

auto finalCommitments = curSession->FinalizeCommitments();
for (const auto& fqc : finalCommitments) {
Expand Down
5 changes: 3 additions & 2 deletions src/llmq/quorums_signing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -562,10 +562,11 @@ CQuorumCPtr CSigningManager::SelectQuorumForSigning(Consensus::LLMQType llmqType
uint256 startBlock;
{
LOCK(cs_main);
if (signHeight > chainActive.Height()) {
int startBlockHeight = signHeight - SIGN_HEIGHT_OFFSET;
if (startBlockHeight > chainActive.Height()) {
return nullptr;
}
startBlock = chainActive[signHeight - SIGN_HEIGHT_OFFSET]->GetBlockHash();
startBlock = chainActive[startBlockHeight]->GetBlockHash();
}

auto quorums = quorumManager->ScanQuorums(llmqType, startBlock, poolSize);
Expand Down

0 comments on commit 088525b

Please sign in to comment.