From 07af856ef1473c8e40d0634e97ef857c690479d6 Mon Sep 17 00:00:00 2001 From: "Wladimir J. van der Laan" Date: Thu, 29 Aug 2019 15:41:18 +0200 Subject: [PATCH 1/3] Merge #15615: Add log output during initial header sync d75e704ac08fb43320e3ebcdde0d2a5392fdec9f Add log output during initial header sync (Jonas Schnelli) Pull request description: The non debug log output is completely quiet during the header sync. I see two main reasons to add infos about the state of the initial header sync... * users may think the node did fail to start sync * it's a little complicate to check if your getting throttled during header sync (repeatedly calling `getchaintips` or similar) ACKs for top commit: fanquake: Concept ACK https://github.com/bitcoin/bitcoin/pull/15615/commits/d75e704ac08fb43320e3ebcdde0d2a5392fdec9f practicalswift: utACK d75e704ac08fb43320e3ebcdde0d2a5392fdec9f laanwj: Tested ACK d75e704ac08fb43320e3ebcdde0d2a5392fdec9f Tree-SHA512: 2e738571b703d7251290864603c3a829729645962c2fa3187250bab0585e66a5f01fce892e9b5b98da451fab2b40a2e4784f9b2e5a9cad75ff62c535affe7430 --- src/validation.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/validation.cpp b/src/validation.cpp index db78491b05..6da834a081 100644 --- a/src/validation.cpp +++ b/src/validation.cpp @@ -4020,6 +4020,12 @@ bool ProcessNewBlockHeaders(const std::vector& headers, CValidatio } } NotifyHeaderTip(); + { + LOCK(cs_main); + if (::ChainstateActive().IsInitialBlockDownload() && ppindex && *ppindex) { + LogPrintf("Synchronizing blockheaders, height: %d (~%.2f%%)\n", (*ppindex)->nHeight, 100.0/((*ppindex)->nHeight+(GetAdjustedTime() - (*ppindex)->GetBlockTime()) / Params().GetConsensus().nPowTargetSpacing) * (*ppindex)->nHeight); + } + } return true; } From 2996f593ef2e829f2d2c3310aac3edc9fdb011a1 Mon Sep 17 00:00:00 2001 From: MarcoFalke Date: Tue, 3 Sep 2019 16:39:08 -0400 Subject: [PATCH 2/3] Merge #16774: Avoid unnecessary "Synchronizing blockheaders" log messages dcc448e3d2b97f7e4e23f5ed174762cec3530306 Avoid unnecessary "Synchronizing blockheaders" log messages (Jonas Schnelli) Pull request description: Fixes #16773 I'm not entirely sure why 16773 happend, but probably due to headers fallback in a compact block. However, this PR should fix it and should have been included in #15615. ACKs for top commit: ajtowns: ACK dcc448e3d2b97f7e4e23f5ed174762cec3530306 ; code review only, haven't compiled or tested. promag: ACK dcc448e3d2b97f7e4e23f5ed174762cec3530306. TheBlueMatt: utACK dcc448e3d2b97f7e4e23f5ed174762cec3530306. Went and read how pindexBestHeader is handled and this code looks correct (worst case it breaks a LogPrint, so whatever). I also ran into this on #16762. fanquake: ACK dcc448e3d2b97f7e4e23f5ed174762cec3530306 Tree-SHA512: f8cac3b6eb9d4e8fab53a535b55f9ea9b058e3ab6ade64801ebc56439ede4f54b5fee36d5d2b316966ab987b65b13ab9dc18849f345d08b81ecdf2722a3f5f5a --- src/validation.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/validation.cpp b/src/validation.cpp index 6da834a081..5df910b973 100644 --- a/src/validation.cpp +++ b/src/validation.cpp @@ -3011,7 +3011,7 @@ bool CChainState::ActivateBestChainStep(CValidationState& state, const CChainPar return true; } -static void NotifyHeaderTip() LOCKS_EXCLUDED(cs_main) { +static bool NotifyHeaderTip() LOCKS_EXCLUDED(cs_main) { bool fNotify = false; bool fInitialBlockDownload = false; static CBlockIndex* pindexHeaderOld = nullptr; @@ -3031,6 +3031,7 @@ static void NotifyHeaderTip() LOCKS_EXCLUDED(cs_main) { uiInterface.NotifyHeaderTip(fInitialBlockDownload, pindexHeader); GetMainSignals().NotifyHeaderTip(pindexHeader, fInitialBlockDownload); } + return fNotify; } static void LimitValidationInterfaceQueue() LOCKS_EXCLUDED(cs_main) { @@ -4019,8 +4020,7 @@ bool ProcessNewBlockHeaders(const std::vector& headers, CValidatio } } } - NotifyHeaderTip(); - { + if (NotifyHeaderTip()) { LOCK(cs_main); if (::ChainstateActive().IsInitialBlockDownload() && ppindex && *ppindex) { LogPrintf("Synchronizing blockheaders, height: %d (~%.2f%%)\n", (*ppindex)->nHeight, 100.0/((*ppindex)->nHeight+(GetAdjustedTime() - (*ppindex)->GetBlockTime()) / Params().GetConsensus().nPowTargetSpacing) * (*ppindex)->nHeight); From 4bf53b1931ea1c64e1f3d53ae9b8607a08cfaf97 Mon Sep 17 00:00:00 2001 From: MarcoFalke Date: Fri, 6 Sep 2019 13:58:27 +0200 Subject: [PATCH 3/3] Merge #16793: refactor: Avoid locking cs_main in ProcessNewBlockHeaders MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 3109a1f948f3c8fd500defbdc4e59bfb2953c30b refactor: Avoid locking cs_main in ProcessNewBlockHeaders (João Barbosa) Pull request description: Builds on #16774, this change avoids locking `cs_main` in `ProcessNewBlockHeaders` when the tip has changed - in this case the removed lock was necessary to just log a message. Top commit has no ACKs. Tree-SHA512: 31be6d319fa122804f72fa813cec5ed041dd7e4aef3c1921124a1f03016925c43cd4d9a272d80093e77fa7600e3506ef47b7bb821afcbffe01e6be9bceb6dc00 --- src/validation.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/validation.cpp b/src/validation.cpp index 5df910b973..b37f262f79 100644 --- a/src/validation.cpp +++ b/src/validation.cpp @@ -4021,7 +4021,6 @@ bool ProcessNewBlockHeaders(const std::vector& headers, CValidatio } } if (NotifyHeaderTip()) { - LOCK(cs_main); if (::ChainstateActive().IsInitialBlockDownload() && ppindex && *ppindex) { LogPrintf("Synchronizing blockheaders, height: %d (~%.2f%%)\n", (*ppindex)->nHeight, 100.0/((*ppindex)->nHeight+(GetAdjustedTime() - (*ppindex)->GetBlockTime()) / Params().GetConsensus().nPowTargetSpacing) * (*ppindex)->nHeight); }