Skip to content

Commit 846fd9a

Browse files
codablockpanleone
authored andcommitted
Make LLMQ/InstantSend/ChainLocks code less spammy (#2781)
* Add support for log category to CBatchedLogger * Use "llmq" logging category in LLMQ code * Use "chainlocks" logging category in ChainLocks code * Log errors without logging category
1 parent 1a52ad0 commit 846fd9a

File tree

6 files changed

+46
-42
lines changed

6 files changed

+46
-42
lines changed

src/llmq/quorums.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ void CQuorum::StartCachePopulatorThread(std::shared_ptr<CQuorum> _this)
141141
}
142142

143143
cxxtimer::Timer t(true);
144-
LogPrintf("CQuorum::StartCachePopulatorThread -- start\n");
144+
LogPrint(BCLog::LLMQ, "CQuorum::StartCachePopulatorThread -- start\n");
145145

146146
// this thread will exit after some time
147147
// when then later some other thread tries to get keys, it will be much faster
@@ -151,7 +151,7 @@ void CQuorum::StartCachePopulatorThread(std::shared_ptr<CQuorum> _this)
151151
_this->GetPubKeyShare(i);
152152
}
153153
}
154-
LogPrintf("CQuorum::StartCachePopulatorThread -- done. time=%d\n", t.count());
154+
LogPrint(BCLog::LLMQ, "CQuorum::StartCachePopulatorThread -- done. time=%d\n", t.count());
155155
});
156156
}
157157

@@ -195,7 +195,7 @@ bool CQuorumManager::BuildQuorumFromCommitment(const CFinalCommitment& qc, const
195195
quorum->WriteContributions(evoDb);
196196
hasValidVvec = true;
197197
} else {
198-
LogPrintf("CQuorumManager::%s -- quorum.ReadContributions and BuildQuorumContributions for block %s failed\n", __func__, qc.quorumHash.ToString());
198+
LogPrint(BCLog::LLMQ, "CQuorumManager::%s -- quorum.ReadContributions and BuildQuorumContributions for block %s failed\n", __func__, qc.quorumHash.ToString());
199199
}
200200
}
201201

@@ -224,20 +224,20 @@ bool CQuorumManager::BuildQuorumContributions(const CFinalCommitment& fqc, std::
224224
cxxtimer::Timer t2(true);
225225
quorumVvec = blsWorker.BuildQuorumVerificationVector(vvecs);
226226
if (quorumVvec == nullptr) {
227-
LogPrintf("CQuorumManager::%s -- failed to build quorumVvec\n", __func__);
227+
LogPrint(BCLog::LLMQ, "CQuorumManager::%s -- failed to build quorumVvec\n", __func__);
228228
// without the quorum vvec, there can't be a skShare, so we fail here. Failure is not fatal here, as it still
229229
// allows to use the quorum as a non-member (verification through the quorum pub key)
230230
return false;
231231
}
232232
skShare = blsWorker.AggregateSecretKeys(skContributions);
233233
if (!skShare.IsValid()) {
234-
LogPrintf("CQuorumManager::%s -- failed to build skShare\n", __func__);
234+
LogPrint(BCLog::LLMQ, "CQuorumManager::%s -- failed to build skShare\n", __func__);
235235
// We don't bail out here as this is not a fatal error and still allows us to recover public key shares (as we
236236
// have a valid quorum vvec at this point)
237237
}
238238
t2.stop();
239239

240-
LogPrintf("CQuorumManager::%s -- built quorum vvec and skShare. time=%d\n", __func__, t2.count());
240+
LogPrint(BCLog::LLMQ, "CQuorumManager::%s -- built quorum vvec and skShare. time=%d\n", __func__, t2.count());
241241

242242
quorum->quorumVvec = quorumVvec;
243243
quorum->skShare = skShare;

src/llmq/quorums_chainlocks.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,8 +158,8 @@ void CChainLocksHandler::ProcessNewChainLock(NodeId from, const llmq::CChainLock
158158
},
159159
0);
160160

161-
LogPrintf("CChainLocksHandler::%s -- processed new CLSIG (%s), peer=%d\n",
162-
__func__, clsig.ToString(), from);
161+
LogPrint(BCLog::LLMQ, "CChainLocksHandler::%s -- processed new CLSIG (%s), peer=%d\n",
162+
__func__, clsig.ToString(), from);
163163
}
164164

165165
void CChainLocksHandler::AcceptedBlockHeader(const CBlockIndex* pindexNew)
@@ -247,6 +247,8 @@ void CChainLocksHandler::TrySignChainTip()
247247
}
248248
}
249249

250+
LogPrint(BCLog::LLMQ, "CChainLocksHandler::%s -- trying to sign %s, height=%d\n", __func__, pindex->GetBlockHash().ToString(), pindex->nHeight);
251+
250252
uint256 requestId = ::SerializeHash(std::make_pair(CLSIG_REQUESTID_PREFIX, pindex->nHeight));
251253
uint256 msgHash = pindex->GetBlockHash();
252254

src/llmq/quorums_signing.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ void CSigningManager::ProcessMessageRecoveredSig(CNode* pfrom, const CRecoveredS
299299
return;
300300
}
301301

302-
LogPrintf("llmq", "CSigningManager::%s -- signHash=%s, node=%d\n", __func__, llmq::utils::BuildSignHash(recoveredSig).ToString(), pfrom->GetId());
302+
LogPrint(BCLog::LLMQ, "CSigningManager::%s -- signHash=%s, node=%d\n", __func__, llmq::utils::BuildSignHash(recoveredSig).ToString(), pfrom->GetId());
303303

304304
LOCK(cs);
305305
pendingRecoveredSigs[pfrom->GetId()].emplace_back(recoveredSig);
@@ -318,7 +318,7 @@ bool CSigningManager::PreVerifyRecoveredSig(NodeId nodeId, const CRecoveredSig&
318318
CQuorumCPtr quorum = quorumManager->GetQuorum(llmqType, recoveredSig.quorumHash);
319319

320320
if (!quorum) {
321-
LogPrintf("CSigningManager::%s -- quorum %s not found, node=%d\n", __func__,
321+
LogPrint(BCLog::LLMQ, "CSigningManager::%s -- quorum %s not found, node=%d\n", __func__,
322322
recoveredSig.quorumHash.ToString(), nodeId);
323323
return false;
324324
}
@@ -377,13 +377,13 @@ void CSigningManager::CollectPendingRecoveredSigsToVerify(
377377
if (!retQuorums.count(quorumKey)) {
378378
CQuorumCPtr quorum = quorumManager->GetQuorum(llmqType, recSig.quorumHash);
379379
if (!quorum) {
380-
LogPrintf("CSigningManager::%s -- quorum %s not found, node=%d\n", __func__,
380+
LogPrint(BCLog::LLMQ, "CSigningManager::%s -- quorum %s not found, node=%d\n", __func__,
381381
recSig.quorumHash.ToString(), nodeId);
382382
it = v.erase(it);
383383
continue;
384384
}
385385
if (!llmq::utils::IsQuorumActive(llmqType, quorum->pindexQuorum->GetBlockHash())) {
386-
LogPrintf("CSigningManager::%s -- quorum %s not active anymore, node=%d\n", __func__,
386+
LogPrint(BCLog::LLMQ, "CSigningManager::%s -- quorum %s not active anymore, node=%d\n", __func__,
387387
recSig.quorumHash.ToString(), nodeId);
388388
it = v.erase(it);
389389
continue;
@@ -427,7 +427,7 @@ bool CSigningManager::ProcessPendingRecoveredSigs(CConnman& connman)
427427
batchVerifier.Verify();
428428
verifyTimer.stop();
429429

430-
LogPrintf("llmq", "CSigningManager::%s -- verified recovered sig(s). count=%d, vt=%d, nodes=%d\n", __func__, verifyCount, verifyTimer.count(), recSigsByNode.size());
430+
LogPrint(BCLog::LLMQ, "CSigningManager::%s -- verified recovered sig(s). count=%d, vt=%d, nodes=%d\n", __func__, verifyCount, verifyTimer.count(), recSigsByNode.size());
431431

432432
std::unordered_set<uint256, StaticSaltedHasher> processed;
433433
for (auto& p : recSigsByNode) {
@@ -436,7 +436,7 @@ bool CSigningManager::ProcessPendingRecoveredSigs(CConnman& connman)
436436

437437
if (batchVerifier.badSources.count(nodeId)) {
438438
LOCK(cs_main);
439-
LogPrintf("llmq", "CSigningManager::%s -- invalid recSig from other node, banning peer=%d\n", __func__, nodeId);
439+
LogPrintf("CSigningManager::%s -- invalid recSig from other node, banning peer=%d\n", __func__, nodeId);
440440
Misbehaving(nodeId, 100);
441441
continue;
442442
}
@@ -470,7 +470,7 @@ void CSigningManager::ProcessRecoveredSig(NodeId nodeId, const CRecoveredSig& re
470470

471471
auto signHash = llmq::utils::BuildSignHash(recoveredSig);
472472

473-
LogPrintf("CSigningManager::%s -- valid recSig. signHash=%s, id=%s, msgHash=%s, node=%d\n", __func__,
473+
LogPrint(BCLog::LLMQ, "CSigningManager::%s -- valid recSig. signHash=%s, id=%s, msgHash=%s, node=%d\n", __func__,
474474
signHash.ToString(), recoveredSig.id.ToString(), recoveredSig.msgHash.ToString(), nodeId);
475475

476476
if (db.HasRecoveredSigForId(llmqType, recoveredSig.id)) {
@@ -550,7 +550,7 @@ bool CSigningManager::AsyncSignIfMember(Consensus::LLMQType llmqType, const uint
550550
LogPrintf("CSigningManager::%s -- already voted for id=%s and msgHash=%s. Not voting on conflicting msgHash=%s\n", __func__,
551551
id.ToString(), prevMsgHash.ToString(), msgHash.ToString());
552552
} else {
553-
LogPrintf("CSigningManager::%s -- already voted for id=%s and msgHash=%s. Not voting again.\n", __func__,
553+
LogPrint(BCLog::LLMQ, "CSigningManager::%s -- already voted for id=%s and msgHash=%s. Not voting again.\n", __func__,
554554
id.ToString(), prevMsgHash.ToString());
555555
}
556556
return false;
@@ -576,12 +576,12 @@ bool CSigningManager::AsyncSignIfMember(Consensus::LLMQType llmqType, const uint
576576
// TODO fix this by re-signing when the next block arrives, but only when that block results in a change of the quorum list and no recovered signature has been created in the mean time
577577
CQuorumCPtr quorum = SelectQuorumForSigning(llmqType, tipHeight, id);
578578
if (!quorum) {
579-
LogPrintf("CSigningManager::%s -- failed to select quorum. id=%s, msgHash=%s\n", __func__, id.ToString(), msgHash.ToString());
579+
LogPrint(BCLog::LLMQ, "CSigningManager::%s -- failed to select quorum. id=%s, msgHash=%s\n", __func__, id.ToString(), msgHash.ToString());
580580
return false;
581581
}
582582

583583
if (!quorum->IsValidMember(activeMasternodeManager->GetProTx())) {
584-
// LogPrintf("CSigningManager::%s -- we're not a valid member of quorum %s\n", __func__, quorum->quorumHash.ToString());
584+
// LogPrint(BCLog::LLMQ, "CSigningManager::%s -- we're not a valid member of quorum %s\n", __func__, quorum->quorumHash.ToString());
585585
return false;
586586
}
587587

0 commit comments

Comments
 (0)