-
Notifications
You must be signed in to change notification settings - Fork 37.7k
Log successful AcceptBlockHeader() #27276
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. ReviewsSee the guideline for information on the review process.
If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Concept ACK
src/validation.cpp
Outdated
@@ -3828,6 +3828,7 @@ bool ChainstateManager::AcceptBlockHeader(const CBlockHeader& block, BlockValida | |||
return state.Invalid(BlockValidationResult::BLOCK_HEADER_LOW_WORK, "too-little-chainwork"); | |||
} | |||
CBlockIndex* pindex{m_blockman.AddToBlockIndex(block, m_best_header)}; | |||
LogPrint(BCLog::VALIDATION, "%s: added new block header %s\n", __func__, hash.ToString()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LogPrint(BCLog::VALIDATION, "%s: added new block header %s\n", __func__, hash.ToString()); | |
LogPrint(BCLog::VALIDATION, "added new block header %s\n", hash.ToString()); |
We have an option for logging source locations -logsourcelocations
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done!
a6f9809
to
c8d044e
Compare
Beat 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 |
I opened #27277 to make (just pushed another commit there to move |
cc @0xB10C |
src/validation.cpp
Outdated
@@ -3828,6 +3828,7 @@ bool ChainstateManager::AcceptBlockHeader(const CBlockHeader& block, BlockValida | |||
return state.Invalid(BlockValidationResult::BLOCK_HEADER_LOW_WORK, "too-little-chainwork"); | |||
} | |||
CBlockIndex* pindex{m_blockman.AddToBlockIndex(block, m_best_header)}; | |||
LogPrint(BCLog::VALIDATION, "added new block header %s\n", hash.ToString()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LogPrint
is being migrated to LogPrintLevel
-- you can use that when adding logging. Or LogPrintfCategory
if you decide to make this logged unconditionally, but the former with a level of, say, info, may suffice; example below.
LogPrint(BCLog::VALIDATION, "added new block header %s\n", hash.ToString()); | |
LogPrintLevel(BCLog::VALIDATION, BCLog::Level::Info, "added new block header %s\n", hash.ToString()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
Knowing when a header was first seen may help distinguish between a regular reorg and a selfish mining or eclipse attack.
c8d044e
to
3d32b7d
Compare
At this point I prefer #27278, but I'll leave this open in case that PR doesn't make it. This one is (slightly) easier to review. |
Closing in favour of #27278. |
2c3a90f log: on new valid header (James O'Beirne) e5ce857 log: net: new header over cmpctblock (James O'Beirne) Pull request description: Alternate to #27276. Devs were [suprised to realize](https://twitter.com/jamesob/status/1637237917201383425) last night that we don't have definitive logging for when a given header was first received. This logs to the main stream when new headers are received outside of IBD, as well as when headers come in over cmpctblocks. The rationale of not hiding these under log categories is that they may be useful to have widely available when debugging strange network activity, and the marginal volume is modest. ACKs for top commit: dergoegge: Code review ACK 2c3a90f achow101: ACK 2c3a90f Sjors: tACK 2c3a90f josibake: ACK 2c3a90f Tree-SHA512: 49fdcbe07799c8adc24143d7e5054a0c93fef120d2e9d5fddbd3b119550d895e2985be6ac10dd1825ea23a6fa5479c1b76d5518c136fbd983fa76c0d39dc354f
2c3a90f log: on new valid header (James O'Beirne) e5ce857 log: net: new header over cmpctblock (James O'Beirne) Pull request description: Alternate to bitcoin#27276. Devs were [suprised to realize](https://twitter.com/jamesob/status/1637237917201383425) last night that we don't have definitive logging for when a given header was first received. This logs to the main stream when new headers are received outside of IBD, as well as when headers come in over cmpctblocks. The rationale of not hiding these under log categories is that they may be useful to have widely available when debugging strange network activity, and the marginal volume is modest. ACKs for top commit: dergoegge: Code review ACK 2c3a90f achow101: ACK 2c3a90f Sjors: tACK 2c3a90f josibake: ACK bitcoin@2c3a90f Tree-SHA512: 49fdcbe07799c8adc24143d7e5054a0c93fef120d2e9d5fddbd3b119550d895e2985be6ac10dd1825ea23a6fa5479c1b76d5518c136fbd983fa76c0d39dc354f
Knowing when a header was first seen may help distinguish between a regular reorg and a selfish mining or eclipse attack.