Provide logging and info to help people
- use the
DEBUG_ADDRMAN
consistency checks - verify the checks are running
- see when and how often they are being performed
Provide logging and info to help people
DEBUG_ADDRMAN
consistency checksThe following sections might be updated with supplementary metadata relevant to reviewers and maintainers.
Reviewers, 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.
Concept ACK
I see how this can be useful and is a nice addition. After following your instructions, my debug file is filled with thousands of lines of:
02021-07-19T04:37:25Z Check addrman
12021-07-19T04:37:25Z ADDRMAN CONSISTENCY CHECK FAILED!!! err=-19
Wonder what other useful information could be logged.
282@@ -282,6 +283,20 @@ configure option adds `-DDEBUG_LOCKORDER` to the compiler flags. This inserts
283 run-time checks to keep track of which locks are held and adds warnings to the
284 `debug.log` file if inconsistencies are detected.
285
286+### DEBUG_ADDRMAN
287+
288+Defining `DEBUG_ADDRMAN` performs frequent (and expensive) consistency checks on
289+the entire addrman data structure. Add this line to enable it, e.g. in
src/addrman.h
the only file we could define this in? Are there other files we could do this in. If there are I feel as though we could improve the note here. Otherwise, we could remove e.g
.
Good point. Improved as follows:
0 Defining `DEBUG_ADDRMAN` performs frequent (and expensive) consistency checks on
1-the entire addrman data structure. Add this line to enable it, e.g. in
2-`src/addrman.h`
3+the entire addrman data structure. To enable it, add this line in `src/addrman.h`
4+before `void Check()`
291+
292+```cpp
293+#define DEBUG_ADDRMAN
294+```
295+
296+and then build (`make`) and run bitcoind. You can use the `-debug=addrman`
0then build (`make`) and run bitcoind. You can use the `-debug=addrman`
cr ACK 68ebaa03f42732e70ab6922def36b3eaaeee8b50
Making this more clear makes sense since one might incorrectly assume that --enable-debug
would define DEBUG_ADDRMAN
.
ACK 68ebaa03f42732e70ab6922def36b3eaaeee8b50
I remember enabling DEBUG_ADDRMAN
once as described, but asking myself if I was really supposed to do it this way.
282@@ -282,6 +283,20 @@ configure option adds `-DDEBUG_LOCKORDER` to the compiler flags. This inserts
283 run-time checks to keep track of which locks are held and adds warnings to the
284 `debug.log` file if inconsistencies are detected.
285
286+### DEBUG_ADDRMAN
287+
288+Defining `DEBUG_ADDRMAN` performs frequent (and expensive) consistency checks on
289+the entire addrman data structure. To enable it, add this line in `src/addrman.h`
-DDEBUG_ADDRMAN
to your CPPFLAGS, rather than modifying the source.
ACK baac29c74e475a1e7239355e710f2c6ad0cd19e0
Tested on signet. #20233 seems to be a very promising long-term alternative by allowing activating addrman consistency checks at runtime. Right now, the documentation introduced in this PR will serve as a good and useful guide in how to properly use the compile-time debug option 👍. Logging the consistency checks also makes a lot of sense.