-
Notifications
You must be signed in to change notification settings - Fork 36.3k
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
log: Add validation interface logging #16688
Conversation
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. ConflictsReviewers, this pull request conflicts with the following ones:
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first. |
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.
Tested validationinterface log flag with both cli option and logging RPC. Worked as expected.
Nice to have more logging around the validation callbacks, order of events may be so confusing!
Concept ACK |
e13e0f8
to
b303865
Compare
Addressed all comments and add correct formatting for valid Also updated |
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.
I've partially reviewed and left a few comments inline. I intend to finish review and test this week.
I did some light testing and this looks good. If you wanted to add automated tests, take a look at
Was this required for the PR? Those accessors aren't used very much, so performance isn't critical. I'd suggest not changing them in this PR. |
4b876d7
to
72c6e50
Compare
I would be hesitant to add a functional test only to check for informational logging. Is there an existing a test where all these events are exercised? Not sure if it is worth adding regardless.
Yeah, commit 72c6e50 calls those methods in such a way that not returning references would have incurred excessive copies. Would it be better if the two commits were merged? |
72c6e50
to
515e3ee
Compare
@jnewbery I have some concerns about this additional logging. Since #14209 was merged, all log function arguments are evaluated regardless of whether logging is enabled for the given category. This was not the case prior to that PR since a macro was used for logging. Given the heavy amount of logging added in this PR, should the function vs macro approach for logging be revisited? Typically, the use of macros in logging libraries is to avoid such argument evaluation if I understand correctly. |
Huh? They were passed to |
By evaluation I mean at the call site of |
Ah, right |
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.
IMO, 6c730c3 commit is outside the original PR goal.
Also string
(i.e., basic_string<char>
) offers move semantics; so it can be efficiently return by value.
4c89052
to
f83a38f
Compare
I removed the commit. But I don't believe move semantics apply here as the function is returning a member variable. |
Thanks! I've tested this and it works great. I think we need to resolve this question: #16688 (comment) before merging this PR. It seems reasonable to me to change logging back to using a macro for the reasons you suggest. Adding a Rename CMainSignals::MempoolEntryRemoved to TransactionRemovedFromMempool and Format CValidationState properly in all cases could be pulled out into their own PR while we're waiting for that, although note that Format CValidationState properly in all cases conflicts with 0053e16. |
@jnewbery Will do. @MarcoFalke I'm not sure I follow the part about "unnecessary branches are not analyzed" in #14209. If I were to make |
If you revert #14209, please make it as slim as possible (without the USE_COVERAGE guard, which mostly did only harm) |
Yeah, I agree that this isn't necessary. |
Calling LogPrint with a category that is not enabled results in evaluating the remaining function arguments, which may be arbitrarily complex (and possibly expensive) expressions. Defining LogPrint as a macro prevents this unnecessary expression evaluation. This is a partial revert of bitcoin#14209. The decision to revert is discussed in bitcoin#16688, which adds verbose logging for validation event notification.
Calling LogPrint with a category that is not enabled results in evaluating the remaining function arguments, which may be arbitrarily complex (and possibly expensive) expressions. Defining LogPrint as a macro prevents this unnecessary expression evaluation. This is a partial revert of bitcoin#14209. The decision to revert is discussed in bitcoin#16688, which adds verbose logging for validation event notification.
This could help debug issues where there may be race conditions at play, such as bitcoin#12978. Fixes bitcoin#12994.
0cadb12
to
f9abf4a
Compare
@hebasto @ryanofsky Thanks for the review! I've addressed all comments. |
ACK f9abf4a |
1 similar comment
ACK f9abf4a |
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.
Code review ACK f9abf4a. Just suggested changes since last review (thanks!)
f9abf4a Add logging for CValidationInterface events (Jeffrey Czyz) 6edebac Refactor FormatStateMessage for clarity (Jeffrey Czyz) 72f3227 Format CValidationState properly in all cases (Jeffrey Czyz) 428ac70 Add VALIDATION to BCLog::LogFlags (Jeffrey Czyz) Pull request description: Add logging of `CValidationInterface` callbacks using a new `VALIDATIONINTERFACE` log flag (see #12994). A separate flag is desirable as the logging can be noisy and thus may need to be disabled without affecting other logging. This could help debug issues where there may be race conditions at play, such as #12978. ACKs for top commit: jnewbery: ACK f9abf4a hebasto: ACK f9abf4a ariard: ACK f9abf4a, only changes since 0cadb12 are replacing log indication `VALIDATIONINTERFACE` by `VALIDATION` and avoiding a forward declaration with a new include ryanofsky: Code review ACK f9abf4a. Just suggested changes since last review (thanks!) Tree-SHA512: 3e0f6e2c8951cf46fbad3ff440971d95d526df2a52a2e4d6452a82785c63d53accfdabae66b0b30e2fe0b00737f8d5cb717edbad1460b63acb11a72c8f5d4236
f9abf4a Add logging for CValidationInterface events (Jeffrey Czyz) 6edebac Refactor FormatStateMessage for clarity (Jeffrey Czyz) 72f3227 Format CValidationState properly in all cases (Jeffrey Czyz) 428ac70 Add VALIDATION to BCLog::LogFlags (Jeffrey Czyz) Pull request description: Add logging of `CValidationInterface` callbacks using a new `VALIDATIONINTERFACE` log flag (see bitcoin#12994). A separate flag is desirable as the logging can be noisy and thus may need to be disabled without affecting other logging. This could help debug issues where there may be race conditions at play, such as bitcoin#12978. ACKs for top commit: jnewbery: ACK f9abf4a hebasto: ACK f9abf4a ariard: ACK f9abf4a, only changes since 0cadb12 are replacing log indication `VALIDATIONINTERFACE` by `VALIDATION` and avoiding a forward declaration with a new include ryanofsky: Code review ACK f9abf4a. Just suggested changes since last review (thanks!) Tree-SHA512: 3e0f6e2c8951cf46fbad3ff440971d95d526df2a52a2e4d6452a82785c63d53accfdabae66b0b30e2fe0b00737f8d5cb717edbad1460b63acb11a72c8f5d4236
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.
ACK e7f8450 posthumous code review and manual tests.
Usage listed here for visitor convenience (the PR description was not updated from validationinterface to validation):
bitcoind -help | grep -B6 ", validation"
-debug=<category>
Output debugging information (default: -nodebug, supplying <category> is
optional). If <category> is not supplied or if <category> = 1,
output all debugging information. <category> can be: net, tor,
mempool, http, bench, zmq, walletdb, rpc, estimatefee, addrman,
selectcoins, reindex, cmpctblock, rand, prune, proxy, mempoolrej,
libevent, coindb, qt, leveldb, validation.
bitcoind -debug=validation
(launch bitcoind with validation logging)bitcoin-cli help logging
bitcoin-cli logging [] '["validation"]'
(toggle validation logging off)bitcoin-cli logging '["validation"]'
(toggle validation logging on)
This flag is for logging from within CValidationInterface (see bitcoin#12994). A separate flag is desirable as the logging can be noisy and thus may need to be disabled without affecting other logging. Github-Pull: bitcoin#16688 Rebased-From: 428ac70
This flag is for logging from within CValidationInterface (see bitcoin#12994). A separate flag is desirable as the logging can be noisy and thus may need to be disabled without affecting other logging. Github-Pull: bitcoin#16688 Rebased-From: 428ac70
Summary: f9abf4ab6d3d3e4d4b7e90723020b5422a141a6f Add logging for CValidationInterface events (Jeffrey Czyz) 6edebacb2191373e76d79a4972d6192300976096 Refactor FormatStateMessage for clarity (Jeffrey Czyz) 72f3227c83810936e7a334304e5fd7c6dab8e91b Format CValidationState properly in all cases (Jeffrey Czyz) 428ac70095253225f64462ee15c595644747f376 Add VALIDATION to BCLog::LogFlags (Jeffrey Czyz) Pull request description: Add logging of `CValidationInterface` callbacks using a new `VALIDATIONINTERFACE` log flag (see #12994). A separate flag is desirable as the logging can be noisy and thus may need to be disabled without affecting other logging. This could help debug issues where there may be race conditions at play, such as #12978. ACKs for top commit: jnewbery: ACK f9abf4ab6d3d3e4d4b7e90723020b5422a141a6f hebasto: ACK f9abf4ab6d3d3e4d4b7e90723020b5422a141a6f ariard: ACK f9abf4a, only changes since 0cadb12 are replacing log indication `VALIDATIONINTERFACE` by `VALIDATION` and avoiding a forward declaration with a new include ryanofsky: Code review ACK f9abf4ab6d3d3e4d4b7e90723020b5422a141a6f. Just suggested changes since last review (thanks!) Tree-SHA512: 3e0f6e2c8951cf46fbad3ff440971d95d526df2a52a2e4d6452a82785c63d53accfdabae66b0b30e2fe0b00737f8d5cb717edbad1460b63acb11a72c8f5d4236 Partial backport of [[bitcoin/bitcoin#16688 | PR16688]] The changes to `FormatStateMessage` are completely absent because I did not want to mangle them for the sake of backporting this change, and that particular change depends on a massive stack that isn't necessary to take advantage of this patch. Test Plan: `ninja check check-functional` Reviewers: #bitcoin_abc, Fabien Reviewed By: #bitcoin_abc, Fabien Subscribers: Fabien Differential Revision: https://reviews.bitcoinabc.org/D6652
Summary: This completes the backport of Core [[bitcoin/bitcoin#16688 | PR16688]] (see my note in the summary of D6652). We diverge slightly due to a not-yet-backported change that will remove the RejectCode. Depends on D6860 Test Plan: `ninja check check-functional` Reviewers: #bitcoin_abc, Fabien Reviewed By: #bitcoin_abc, Fabien Differential Revision: https://reviews.bitcoinabc.org/D6862
8734c85 Replace the LogPrint function with a macro (Jeffrey Czyz) Pull request description: Calling `LogPrint` with a category that is not enabled results in evaluating the remaining function arguments, which may be arbitrarily complex (and possibly expensive) expressions. Defining `LogPrint` as a macro prevents this unnecessary expression evaluation. This is a partial revert of bitcoin#14209. The decision to revert is discussed in bitcoin#16688, which adds verbose logging for validation event notification. ACKs for top commit: jnewbery: ACK 8734c85 Tree-SHA512: 19e995eaef0ff008a9f8c1fd6f3882f1fbf6794dd7e2dcf5c68056be787eee198d2956037d4ffba2b01e7658b47eba276cd7132feede78832373b3304203961e
f9abf4a Add logging for CValidationInterface events (Jeffrey Czyz) 6edebac Refactor FormatStateMessage for clarity (Jeffrey Czyz) 72f3227 Format CValidationState properly in all cases (Jeffrey Czyz) 428ac70 Add VALIDATION to BCLog::LogFlags (Jeffrey Czyz) Pull request description: Add logging of `CValidationInterface` callbacks using a new `VALIDATIONINTERFACE` log flag (see bitcoin#12994). A separate flag is desirable as the logging can be noisy and thus may need to be disabled without affecting other logging. This could help debug issues where there may be race conditions at play, such as bitcoin#12978. ACKs for top commit: jnewbery: ACK f9abf4a hebasto: ACK f9abf4a ariard: ACK f9abf4a, only changes since 0cadb12 are replacing log indication `VALIDATIONINTERFACE` by `VALIDATION` and avoiding a forward declaration with a new include ryanofsky: Code review ACK f9abf4a. Just suggested changes since last review (thanks!) Tree-SHA512: 3e0f6e2c8951cf46fbad3ff440971d95d526df2a52a2e4d6452a82785c63d53accfdabae66b0b30e2fe0b00737f8d5cb717edbad1460b63acb11a72c8f5d4236
8734c85 Replace the LogPrint function with a macro (Jeffrey Czyz) Pull request description: Calling `LogPrint` with a category that is not enabled results in evaluating the remaining function arguments, which may be arbitrarily complex (and possibly expensive) expressions. Defining `LogPrint` as a macro prevents this unnecessary expression evaluation. This is a partial revert of bitcoin#14209. The decision to revert is discussed in bitcoin#16688, which adds verbose logging for validation event notification. ACKs for top commit: jnewbery: ACK 8734c85 Tree-SHA512: 19e995eaef0ff008a9f8c1fd6f3882f1fbf6794dd7e2dcf5c68056be787eee198d2956037d4ffba2b01e7658b47eba276cd7132feede78832373b3304203961e
8734c85 Replace the LogPrint function with a macro (Jeffrey Czyz) Pull request description: Calling `LogPrint` with a category that is not enabled results in evaluating the remaining function arguments, which may be arbitrarily complex (and possibly expensive) expressions. Defining `LogPrint` as a macro prevents this unnecessary expression evaluation. This is a partial revert of bitcoin#14209. The decision to revert is discussed in bitcoin#16688, which adds verbose logging for validation event notification. ACKs for top commit: jnewbery: ACK 8734c85 Tree-SHA512: 19e995eaef0ff008a9f8c1fd6f3882f1fbf6794dd7e2dcf5c68056be787eee198d2956037d4ffba2b01e7658b47eba276cd7132feede78832373b3304203961e
8734c85 Replace the LogPrint function with a macro (Jeffrey Czyz) Pull request description: Calling `LogPrint` with a category that is not enabled results in evaluating the remaining function arguments, which may be arbitrarily complex (and possibly expensive) expressions. Defining `LogPrint` as a macro prevents this unnecessary expression evaluation. This is a partial revert of bitcoin#14209. The decision to revert is discussed in bitcoin#16688, which adds verbose logging for validation event notification. ACKs for top commit: jnewbery: ACK 8734c85 Tree-SHA512: 19e995eaef0ff008a9f8c1fd6f3882f1fbf6794dd7e2dcf5c68056be787eee198d2956037d4ffba2b01e7658b47eba276cd7132feede78832373b3304203961e
8734c85 Replace the LogPrint function with a macro (Jeffrey Czyz) Pull request description: Calling `LogPrint` with a category that is not enabled results in evaluating the remaining function arguments, which may be arbitrarily complex (and possibly expensive) expressions. Defining `LogPrint` as a macro prevents this unnecessary expression evaluation. This is a partial revert of bitcoin#14209. The decision to revert is discussed in bitcoin#16688, which adds verbose logging for validation event notification. ACKs for top commit: jnewbery: ACK 8734c85 Tree-SHA512: 19e995eaef0ff008a9f8c1fd6f3882f1fbf6794dd7e2dcf5c68056be787eee198d2956037d4ffba2b01e7658b47eba276cd7132feede78832373b3304203961e
8734c85 Replace the LogPrint function with a macro (Jeffrey Czyz) Pull request description: Calling `LogPrint` with a category that is not enabled results in evaluating the remaining function arguments, which may be arbitrarily complex (and possibly expensive) expressions. Defining `LogPrint` as a macro prevents this unnecessary expression evaluation. This is a partial revert of bitcoin#14209. The decision to revert is discussed in bitcoin#16688, which adds verbose logging for validation event notification. ACKs for top commit: jnewbery: ACK 8734c85 Tree-SHA512: 19e995eaef0ff008a9f8c1fd6f3882f1fbf6794dd7e2dcf5c68056be787eee198d2956037d4ffba2b01e7658b47eba276cd7132feede78832373b3304203961e
8734c85 Replace the LogPrint function with a macro (Jeffrey Czyz) Pull request description: Calling `LogPrint` with a category that is not enabled results in evaluating the remaining function arguments, which may be arbitrarily complex (and possibly expensive) expressions. Defining `LogPrint` as a macro prevents this unnecessary expression evaluation. This is a partial revert of bitcoin#14209. The decision to revert is discussed in bitcoin#16688, which adds verbose logging for validation event notification. ACKs for top commit: jnewbery: ACK 8734c85 Tree-SHA512: 19e995eaef0ff008a9f8c1fd6f3882f1fbf6794dd7e2dcf5c68056be787eee198d2956037d4ffba2b01e7658b47eba276cd7132feede78832373b3304203961e
8734c85 Replace the LogPrint function with a macro (Jeffrey Czyz) Pull request description: Calling `LogPrint` with a category that is not enabled results in evaluating the remaining function arguments, which may be arbitrarily complex (and possibly expensive) expressions. Defining `LogPrint` as a macro prevents this unnecessary expression evaluation. This is a partial revert of bitcoin#14209. The decision to revert is discussed in bitcoin#16688, which adds verbose logging for validation event notification. ACKs for top commit: jnewbery: ACK 8734c85 Tree-SHA512: 19e995eaef0ff008a9f8c1fd6f3882f1fbf6794dd7e2dcf5c68056be787eee198d2956037d4ffba2b01e7658b47eba276cd7132feede78832373b3304203961e
8734c85 Replace the LogPrint function with a macro (Jeffrey Czyz) Pull request description: Calling `LogPrint` with a category that is not enabled results in evaluating the remaining function arguments, which may be arbitrarily complex (and possibly expensive) expressions. Defining `LogPrint` as a macro prevents this unnecessary expression evaluation. This is a partial revert of bitcoin#14209. The decision to revert is discussed in bitcoin#16688, which adds verbose logging for validation event notification. ACKs for top commit: jnewbery: ACK 8734c85 Tree-SHA512: 19e995eaef0ff008a9f8c1fd6f3882f1fbf6794dd7e2dcf5c68056be787eee198d2956037d4ffba2b01e7658b47eba276cd7132feede78832373b3304203961e
d6fe150 Add logging for CValidationInterface events (random-zebra) d1036c3 Refactor FormatStateMessage for clarity (Jeffrey Czyz) d19c880 Format CValidationState properly in all cases (Jeffrey Czyz) 888eeac [Build] add util/validation build unit (random-zebra) dbbf00b Add VALIDATION to BCLog::LogFlags (Jeffrey Czyz) Pull request description: Backports bitcoin#16688 [jkczyz], which should help us debug some intermittent failures on GA (e.g. for `feature_reindex` or `wallet_basic` tests). > Add logging of CValidationInterface callbacks using a new VALIDATION log flag (see 12994). A separate flag is desirable as the logging can be noisy and thus may need to be disabled without affecting other logging. > > This could help debug issues where there may be race conditions at play, such as 12978. Based on top of - [x] #2547 ACKs for top commit: furszy: utACK d6fe150 after squash. Tree-SHA512: affde45bf630d851c4e61b687e3a25cf5d33ae420630bef7c3d42f4632975a8197dccffa748f5bdb4899288232e73ae6c1967cde3e36b765f0d7d20ffdc4501d
Add logging of
CValidationInterface
callbacks using a newVALIDATION
log flag (see #12994). A separate flag is desirable as the logging can be noisy and thus may need to be disabled without affecting other logging.This could help debug issues where there may be race conditions at play, such as #12978.