Log successful AcceptBlockHeader() #27276
pull Sjors wants to merge 1 commits into bitcoin:master from Sjors:2022/03/log-accept-header changing 1 files +1 −0-
Sjors commented at 12:20 pm on March 19, 2023: memberKnowing when a header was first seen may help distinguish between a regular reorg and a selfish mining or eclipse attack.
-
DrahtBot commented at 12:20 pm on March 19, 2023: contributor
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.
Reviews
See the guideline for information on the review process.
Type Reviewers Concept ACK dergoegge If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update.
-
in src/validation.cpp:3831 in a6f9809bfb outdated
3827@@ -3828,6 +3828,7 @@ bool ChainstateManager::AcceptBlockHeader(const CBlockHeader& block, BlockValida 3828 return state.Invalid(BlockValidationResult::BLOCK_HEADER_LOW_WORK, "too-little-chainwork"); 3829 } 3830 CBlockIndex* pindex{m_blockman.AddToBlockIndex(block, m_best_header)}; 3831+ LogPrint(BCLog::VALIDATION, "%s: added new block header %s\n", __func__, hash.ToString());
dergoegge commented at 1:10 pm on March 19, 2023:0 LogPrint(BCLog::VALIDATION, "added new block header %s\n", hash.ToString());
We have an option for logging source locations
-logsourcelocations
.
Sjors commented at 1:24 pm on March 19, 2023:Done!dergoegge commented at 1:10 pm on March 19, 2023: memberConcept ACKSjors force-pushed on Mar 19, 2023jamesob commented at 1:55 pm on March 19, 2023: memberBeat me to it! I was just about to open this PR :).
For what it’s worth, I think that the right approach here is to make this message
LogPrintf()
and omit it when in initial block download, the rationale being that if something weird happens on the network (like the inspiration for this PR last night), having a lot of data available to investigate would be nice, and most people don’t run with verbose logging. Since the additional log volume here is quite minimal (one extra line per block, basically), I don’t think there’s much cost.Sjors commented at 2:02 pm on March 19, 2023: memberI opened #27277 to make
-debug=validation
less noisy, making it a more attractive setting. At least after IBD, since it produces ~4 lines per block:AcceptBlockHeader
,NewPoWValidBlock
,Pre-allocating
andBlockChecked
.(just pushed another commit there to move
Pre-allocating
to the blockstorage category)Log successful AcceptBlockHeader()
Knowing when a header was first seen may help distinguish between a regular reorg and a selfish mining or eclipse attack.
in src/validation.cpp:3831 in c8d044e8fd outdated
3827@@ -3828,6 +3828,7 @@ bool ChainstateManager::AcceptBlockHeader(const CBlockHeader& block, BlockValida 3828 return state.Invalid(BlockValidationResult::BLOCK_HEADER_LOW_WORK, "too-little-chainwork"); 3829 } 3830 CBlockIndex* pindex{m_blockman.AddToBlockIndex(block, m_best_header)}; 3831+ LogPrint(BCLog::VALIDATION, "added new block header %s\n", hash.ToString());
jonatack commented at 2:40 pm on March 19, 2023:LogPrint
is being migrated toLogPrintLevel
– you can use that when adding logging. OrLogPrintfCategory
if you decide to make this logged unconditionally, but the former with a level of, say, info, may suffice; example below.0 LogPrintLevel(BCLog::VALIDATION, BCLog::Level::Info, "added new block header %s\n", hash.ToString());
Sjors commented at 3:25 pm on March 19, 2023:DoneSjors force-pushed on Mar 19, 2023fanquake closed this on Mar 20, 2023
achow101 referenced this in commit 664500fc71 on Mar 21, 2023sidhujag referenced this in commit 4b54cd3f6c on Mar 21, 2023bitcoin locked this on Mar 19, 2024
This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2024-12-22 06:12 UTC
More mirrored repositories can be found on mirror.b10c.me