Skip to content

Commit a85b450

Browse files
codablockpanleone
authored andcommitted
Merge pull request dashpay#3399 from codablock/pr_speedups2
Avoid unnecessary processing/verification of reconstructed recovered signatures
1 parent 136f900 commit a85b450

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

src/llmq/quorums_signing.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -432,8 +432,10 @@ CSigningManager::CSigningManager(CDBWrapper& llmqDb, bool fMemory) : db(llmqDb)
432432

433433
bool CSigningManager::AlreadyHave(const CInv& inv)
434434
{
435-
LOCK(cs);
436-
return inv.type == MSG_QUORUM_RECOVERED_SIG && db.HasRecoveredSigForHash(inv.hash);
435+
if (inv.type != MSG_QUORUM_RECOVERED_SIG) {
436+
return false;
437+
}
438+
return db.HasRecoveredSigForHash(inv.hash);
437439
}
438440

439441
bool CSigningManager::GetRecoveredSigForGetData(const uint256& hash, CRecoveredSig& ret)

src/llmq/quorums_signing_shares.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -639,6 +639,7 @@ bool CSigSharesManager::ProcessPendingSigShares(CConnman& connman)
639639
// which are not craftable by individual entities, making the rogue public key attack impossible
640640
CBLSBatchVerifier<NodeId, SigShareKey> batchVerifier(false, true);
641641

642+
cxxtimer::Timer prepareTimer(true);
642643
size_t verifyCount = 0;
643644
for (auto& p : sigSharesByNodes) {
644645
auto nodeId = p.first;
@@ -671,12 +672,13 @@ bool CSigSharesManager::ProcessPendingSigShares(CConnman& connman)
671672
verifyCount++;
672673
}
673674
}
675+
prepareTimer.stop();
674676

675677
cxxtimer::Timer verifyTimer(true);
676678
batchVerifier.Verify();
677679
verifyTimer.stop();
678680

679-
LogPrint(BCLog::LLMQ, "CSigSharesManager::%s -- verified sig shares. count=%d, vt=%d, nodes=%d\n", __func__, verifyCount, verifyTimer.count(), sigSharesByNodes.size());
681+
LogPrint(BCLog::LLMQ, "CSigSharesManager::%s -- verified sig shares. count=%d, pt=%d, vt=%d, nodes=%d\n", __func__, verifyCount, prepareTimer.count(), verifyTimer.count(), sigSharesByNodes.size());
680682

681683
for (auto& p : sigSharesByNodes) {
682684
auto nodeId = p.first;
@@ -1022,10 +1024,11 @@ void CSigSharesManager::CollectSigSharesToSend(std::unordered_map<NodeId, std::v
10221024
if (curTime >= p.second.nextAttemptTime) {
10231025
p.second.nextAttemptTime = curTime + SEND_FOR_RECOVERY_TIMEOUT;
10241026
auto dmn = SelectMemberForRecovery(p.second.quorum, p.second.sigShare.id, p.second.attempt);
1025-
LogPrint(BCLog::LLMQ, "CSigSharesManager::%s -- sending to %s, signHash=%s\n", __func__,
1026-
dmn->proTxHash.ToString(), p.second.sigShare.GetSignHash().ToString());
10271027
p.second.attempt++;
10281028

1029+
LogPrint(BCLog::LLMQ, "CSigSharesManager::%s -- signHash=%s, sending to %s, attempt=%d\n", __func__,
1030+
p.second.sigShare.GetSignHash().ToString(), dmn->proTxHash.ToString(), p.second.attempt);
1031+
10291032
auto it = proTxToNode.find(dmn->proTxHash);
10301033
if (it == proTxToNode.end()) {
10311034
continue;

0 commit comments

Comments
 (0)