From cae3fa5619a62835f971134aa453476ee442413a Mon Sep 17 00:00:00 2001 From: Konstantin Akimov Date: Mon, 6 Nov 2023 22:26:36 +0700 Subject: [PATCH] feat: reduce spamming logs with messages from v20 features (#5669) ## Issue being fixed or feature implemented There's too much spamming log items related to new v20 features: credit pool, asset locks, EHF manager, EHF Signaling for MN_RR. Some logs are still spamming after this PR but related code is not changed here https://github.com/dashpay/dash/pull/5658 ## What was done? - Removed some log items, tidy-up other. - logs that supposed to appear for each block are moved to new categories EHF and CREDITPOOL ## How Has This Been Tested? Run unit/functional tests, reviewed log output ## Breaking Changes N/A ## Checklist: - [x] I have performed a self-review of my own code - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] I have added or updated relevant unit/integration/functional/e2e tests - [ ] I have made corresponding changes to the documentation - [x] I have assigned this pull request to a milestone --- src/evo/assetlocktx.cpp | 2 +- src/evo/creditpool.cpp | 5 +++-- src/evo/mnhftx.cpp | 7 ++----- src/evo/specialtxman.cpp | 2 +- src/llmq/ehf_signals.cpp | 8 ++++---- src/logging.h | 5 ++++- src/miner.cpp | 1 - 7 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/evo/assetlocktx.cpp b/src/evo/assetlocktx.cpp index 50258e7f9a..caf7a3e5fd 100644 --- a/src/evo/assetlocktx.cpp +++ b/src/evo/assetlocktx.cpp @@ -124,7 +124,7 @@ bool CAssetUnlockPayload::VerifySig(const uint256& msgHash, gsl::not_nullnHeight < requestedHeight || pindexTip->nHeight >= getHeightToExpiry()) { - LogPrintf("Asset unlock tx %d with requested height %d could not be accepted on height: %d\n", + LogPrint(BCLog::CREDITPOOL, "Asset unlock tx %d with requested height %d could not be accepted on height: %d\n", index, requestedHeight, pindexTip->nHeight); return state.Invalid(TxValidationResult::TX_CONSENSUS, "bad-assetunlock-too-late"); } diff --git a/src/evo/creditpool.cpp b/src/evo/creditpool.cpp index e1b9b95cb9..f0c7690fa7 100644 --- a/src/evo/creditpool.cpp +++ b/src/evo/creditpool.cpp @@ -183,7 +183,8 @@ CCreditPool CCreditPoolManager::ConstructCreditPool(const CBlockIndex* const blo assert(currentLimit >= 0); if (currentLimit > 0 || latelyUnlocked > 0 || locked > 0) { - LogPrintf("CCreditPoolManager: asset unlock limits on height: %d locked: %d.%08d limit: %d.%08d previous: %d.%08d\n", block_index->nHeight, locked / COIN, locked % COIN, + LogPrint(BCLog::CREDITPOOL, "CCreditPoolManager: asset unlock limits on height: %d locked: %d.%08d limit: %d.%08d previous: %d.%08d\n", + block_index->nHeight, locked / COIN, locked % COIN, currentLimit / COIN, currentLimit % COIN, latelyUnlocked / COIN, latelyUnlocked % COIN); } @@ -296,7 +297,7 @@ std::optional GetCreditPoolDiffForBlock(const CBlock& block, co { try { const CCreditPool creditPool = creditPoolManager->GetCreditPool(pindexPrev, consensusParams); - LogPrintf("%s: CCreditPool is %s\n", __func__, creditPool.ToString()); + LogPrint(BCLog::CREDITPOOL, "%s: CCreditPool is %s\n", __func__, creditPool.ToString()); CCreditPoolDiff creditPoolDiff(creditPool, pindexPrev, consensusParams, blockSubsidy); for (size_t i = 1; i < block.vtx.size(); ++i) { const auto& tx = *block.vtx[i]; diff --git a/src/evo/mnhftx.cpp b/src/evo/mnhftx.cpp index c019f18248..37a871c072 100644 --- a/src/evo/mnhftx.cpp +++ b/src/evo/mnhftx.cpp @@ -189,6 +189,7 @@ bool CMNHFManager::ProcessBlock(const CBlock& block, const CBlockIndex* const pi if (!fJustCheck) { AddToCache(signals, pindex); } + LogPrint(BCLog::EHF, "CMNHFManager::ProcessBlock: no new signals; number of known signals: %d\n", signals.size()); return true; } @@ -232,7 +233,7 @@ bool CMNHFManager::UndoBlock(const CBlock& block, const CBlockIndex* const pinde std::vector excluded_signals; BlockValidationState state; if (!extractSignals(block, pindex, excluded_signals, state)) { - LogPrintf("%s: failed to extract signals\n", __func__); + LogPrintf("CMNHFManager::%s: failed to extract signals\n", __func__); return false; } if (excluded_signals.empty()) { @@ -284,20 +285,17 @@ CMNHFManager::Signals CMNHFManager::GetFromCache(const CBlockIndex* const pindex { LOCK(cs_cache); if (mnhfCache.get(blockHash, signals)) { - LogPrintf("CMNHFManager::GetFromCache: mnhf get for block %s from cache: %lld signals\n", pindex->GetBlockHash().ToString(), signals.size()); return signals; } } if (VersionBitsState(pindex->pprev, Params().GetConsensus(), Consensus::DEPLOYMENT_V20, versionbitscache) != ThresholdState::ACTIVE) { LOCK(cs_cache); mnhfCache.insert(blockHash, {}); - LogPrintf("CMNHFManager::GetFromCache: mnhf feature is disabled: return empty for block %s\n", pindex->GetBlockHash().ToString()); return {}; } if (!m_evoDb.Read(std::make_pair(DB_SIGNALS, blockHash), signals)) { LogPrintf("CMNHFManager::GetFromCache: failure: can't read MnEHF signals from db for %s\n", pindex->GetBlockHash().ToString()); } - LogPrintf("CMNHFManager::GetFromCache: mnhf for block %s read from evo: %lld\n", pindex->GetBlockHash().ToString(), signals.size()); LOCK(cs_cache); mnhfCache.insert(blockHash, signals); return signals; @@ -308,7 +306,6 @@ void CMNHFManager::AddToCache(const Signals& signals, const CBlockIndex* const p const uint256& blockHash = pindex->GetBlockHash(); { LOCK(cs_cache); - LogPrintf("CMNHFManager::AddToCache: mnhf for block %s add to cache: %lld\n", pindex->GetBlockHash().ToString(), signals.size()); mnhfCache.insert(blockHash, signals); } m_evoDb.Write(std::make_pair(DB_SIGNALS, blockHash), signals); diff --git a/src/evo/specialtxman.cpp b/src/evo/specialtxman.cpp index 9659478252..f4f7ba4dea 100644 --- a/src/evo/specialtxman.cpp +++ b/src/evo/specialtxman.cpp @@ -149,7 +149,7 @@ bool ProcessSpecialTxsInBlock(const CBlock& block, const CBlockIndex* pindex, CM const CCreditPool creditPool = creditPoolManager->GetCreditPool(pindex->pprev, consensusParams); if (llmq::utils::IsV20Active(pindex->pprev)) { - LogPrintf("%s: CCreditPool is %s\n", __func__, creditPool.ToString()); + LogPrint(BCLog::CREDITPOOL, "%s: CCreditPool is %s\n", __func__, creditPool.ToString()); } for (const auto& ptr_tx : block.vtx) { diff --git a/src/llmq/ehf_signals.cpp b/src/llmq/ehf_signals.cpp index 8e9df7595f..e8660d1c7a 100644 --- a/src/llmq/ehf_signals.cpp +++ b/src/llmq/ehf_signals.cpp @@ -62,8 +62,6 @@ void CEHFSignalsHandler::trySignEHFSignal(int bit, const CBlockIndex* const pind mnhfPayload.signal.versionBit = bit; const uint256 requestId = mnhfPayload.GetRequestId(); - LogPrintf("CEHFSignalsHandler::trySignEHFSignal: bit=%d at height=%d id=%s\n", bit, pindex->nHeight, requestId.ToString()); - const Consensus::LLMQType& llmqType = Params().GetConsensus().llmqTypeMnhf; const auto& llmq_params_opt = llmq::GetLLMQParams(llmqType); if (!llmq_params_opt.has_value()) { @@ -73,6 +71,7 @@ void CEHFSignalsHandler::trySignEHFSignal(int bit, const CBlockIndex* const pind LOCK(cs); ids.insert(requestId); + LogPrint(BCLog::EHF, "CEHFSignalsHandler::trySignEHFSignal: already signed bit=%d at height=%d id=%s\n", bit, pindex->nHeight, requestId.ToString()); // no need to sign same message one more time return; } @@ -83,6 +82,7 @@ void CEHFSignalsHandler::trySignEHFSignal(int bit, const CBlockIndex* const pind return; } + LogPrint(BCLog::EHF, "CEHFSignalsHandler::trySignEHFSignal: bit=%d at height=%d id=%s\n", bit, pindex->nHeight, requestId.ToString()); mnhfPayload.signal.quorumHash = quorum->qc->quorumHash; const uint256 msgHash = mnhfPayload.PrepareTx().GetHash(); @@ -113,10 +113,10 @@ void CEHFSignalsHandler::HandleNewRecoveredSig(const CRecoveredSig& recoveredSig mnhfPayload.signal.versionBit = Params().GetConsensus().vDeployments[Consensus::DEPLOYMENT_MN_RR].bit; const uint256 expectedId = mnhfPayload.GetRequestId(); - LogPrintf("CEHFSignalsHandler::HandleNewRecoveredSig expecting ID=%s received=%s\n", expectedId.ToString(), recoveredSig.getId().ToString()); + LogPrint(BCLog::EHF, "CEHFSignalsHandler::HandleNewRecoveredSig expecting ID=%s received=%s\n", expectedId.ToString(), recoveredSig.getId().ToString()); if (recoveredSig.getId() != mnhfPayload.GetRequestId()) { // there's nothing interesting for CEHFSignalsHandler - LogPrintf("CEHFSignalsHandler::HandleNewRecoveredSig id is known but it's not MN_RR, expected: %s\n", mnhfPayload.GetRequestId().ToString()); + LogPrint(BCLog::EHF, "CEHFSignalsHandler::HandleNewRecoveredSig id is known but it's not MN_RR, expected: %s\n", mnhfPayload.GetRequestId().ToString()); return; } diff --git a/src/logging.h b/src/logging.h index af3423edf8..cf1c6f6f73 100644 --- a/src/logging.h +++ b/src/logging.h @@ -71,9 +71,12 @@ namespace BCLog { COINJOIN = ((uint64_t)1 << 41), SPORK = ((uint64_t)1 << 42), NETCONN = ((uint64_t)1 << 43), + EHF = ((uint64_t)1 << 44), + CREDITPOOL = ((uint64_t)1 << 45), DASH = CHAINLOCKS | GOBJECT | INSTANTSEND | LLMQ | LLMQ_DKG - | LLMQ_SIGS | MNPAYMENTS | MNSYNC | COINJOIN | SPORK | NETCONN, + | LLMQ_SIGS | MNPAYMENTS | MNSYNC | COINJOIN | SPORK | NETCONN + | EHF | CREDITPOOL, NET_NETCONN = NET | NETCONN, // use this to have something logged in NET and NETCONN as well //End Dash diff --git a/src/miner.cpp b/src/miner.cpp index f2298175d4..a3b7272022 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -403,7 +403,6 @@ void BlockAssembler::addPackageTxs(int &nPackagesSelected, int &nDescendantsUpda std::optional creditPoolDiff; if (llmq::utils::IsV20Active(pindexPrev)) { CCreditPool creditPool = creditPoolManager->GetCreditPool(pindexPrev, chainparams.GetConsensus()); - LogPrintf("%s: CCreditPool is %s\n", __func__, creditPool.ToString()); creditPoolDiff.emplace(std::move(creditPool), pindexPrev, chainparams.GetConsensus(), 0); }