Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.Sign up
Make logging for validation optional #6519
Avoid ERROR messages like
Also introduces a consistent format for transaction validation failures that always includes the txid.
I have opted for this approach instead of the one outlined in #5794 to remove all messages, because they provide extra troubleshooting information.
Hmm, have you considered to not print the error immediately, but only report through ValidationState, and then have ProcessMessage choose (optionally) to report the error string it, if any?
That's also more compatible with future modularization of the consensus code, where you want to do the actual logging externally.
Done. CValidationState is augmented with optional debug information, which is logged upstream where possible.
This makes the change larger than originally intended, but the end result is better.
N.B.: I've also removed the logging in
Add status codes specific to AcceptToMempool procession of transactions. These can never happen due to block validation, and must never be sent over the P2P network. Add assertions where appropriate.
It is necessary to be able to concisely log a validation state. Convert CValidationState to a human-readable message for logging.
Remove unnecessary direct logging in CheckTransaction, AcceptToMemoryPool, CheckTxInputs, CScriptCheck::operator() All status information should be returned in the CValidationState. Relevant debug information is also added to the CValidationState using the recently introduced debug message. Do keep the "BUG! PLEASE REPORT THIS! ConnectInputs failed against MANDATORY but not STANDARD flags" error as it is meant to appear as bug in the log.
Add detailed state information to the errors, as it is no longer being logged downstream. Also add the state information to mempool rejection debug message in ProcessMessages.
7f1f8f5 Move mempool rejections to new debug category (Wladimir J. van der Laan) 66daed5 Add information to errors in ConnectBlock, CheckBlock (Wladimir J. van der Laan) 6cab808 Remove most logging from transaction validation (Wladimir J. van der Laan) 9003c7c Add function to convert CValidationState to a human-readable message (Wladimir J. van der Laan) dc58258 Introduce REJECT_INTERNAL codes for local AcceptToMempool errors (Wladimir J. van der Laan) fbf44e6 Add debug message to CValidationState for optional extra information (Wladimir J. van der Laan)
I've been trying to "move error messages up" for consensus and policy functions in different ways and with multiple attempts since at least January 15th 2015 (the first version of #5669 which also moved CheckTransaction to consensus/consensus did that).
Continues "Make logging for validation optional" from bitcoin#6519. The idea there was to remove all ERROR logging of rejected transaction, and move it to one message in the class 'mempoolrej' which logs the state message (and debug info). The superfluous ERRORs in the log "terrify" users, see for example issue bitcoin#5794. Unfortunately a lot of new logging was introduced in bitcoin#6871 (RBF) and bitcoin#7287 (misc refactoring). This pull updates that new code.
ca489c9 [Tests] Fix expected error messages (random-zebra) 9f84c52 Consensus: Remove calls to error() and FormatStateMessage() (random-zebra) 0e4d964 Move mempool rejections to new debug category (random-zebra) e0db16d Add information to errors in ConnectBlock, CheckBlock (random-zebra) d4ed81c Remove most logging from transaction validation (random-zebra) 94b2577 Add function to convert CValidationState to a human-readable message (random-zebra) 1ddc88f Introduce REJECT_INTERNAL codes for local AcceptToMempool errors (random-zebra) 55e00a2 Add debug message to CValidationState for optional extra information (random-zebra) 05cf74b Add absurdly high fee message to validation state (for RPC propagation) (random-zebra) Pull request description: - change `CValidationState::chRejectCode` to int - add `CValidationState::strDebugMessage` for optional information - add `FormatStateMessage` function to convert CValidationState to a human-readable message - introduce REJECT_INTERNAL rejection codes for ATMP and make their logging optional - remove unnecessary direct logging in `CheckTransaction`, `AcceptToMemoryPool`, `CheckTxInputs`, `CScriptCheck::operator()` - add detailed state information to the errors in `CheckBlock` and `ConnectBlock` Backported from: - bitcoin#5913 - bitcoin#6519 - bitcoin#7287 ACKs for top commit: Fuzzbawls: ACK ca489c9 furszy: re ACK ca489c9 and merging Tree-SHA512: ab972801fa45c2f84abf84790b0f0f22dc5668e170f51785f3cfbf806bda7988f55bbd43c24ae591ffe3bd62190f6cd99a3b640373c431ab92c0ddcabea1c999