-
Notifications
You must be signed in to change notification settings - Fork 38.7k
Assert in CAddrMan::Check() #22500
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
Assert in CAddrMan::Check() #22500
Conversation
The same is done in CTxMemPool::check() and other debug checks for developers, like lock order debugging.
|
Approach ACK |
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 cccc47b
Tested with the following changes
--- a/src/addrman.cpp
+++ b/src/addrman.cpp
@@ -463,6 +463,7 @@ void CAddrMan::Check()
{
#ifdef DEBUG_ADDRMAN
AssertLockHeld(cs);
+ LogPrint(BCLog::ADDRMAN, "Check addrman\n");
--- a/src/addrman.h
+++ b/src/addrman.h
@@ -122,6 +122,7 @@ public:
* * Several indexes are kept for high performance. Defining DEBUG_ADDRMAN will introduce frequent (and expensive)
* consistency checks for the entire data structure.
*/
+#define DEBUG_ADDRMAN
//! total number of buckets for tried addresses
#define ADDRMAN_TRIED_BUCKET_COUNT_LOG2 8| assert(setTried.count(vvTried[n][i])); | ||
| assert(mapInfo[vvTried[n][i]].GetTriedBucket(nKey, m_asmap) == n); | ||
| assert(mapInfo[vvTried[n][i]].GetBucketPosition(nKey, false, n) == i); | ||
| setTried.erase(vvTried[n][i]); |
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.
nit, spacing here is off by one
| //! Perform consistency check. Returns an error code or zero. | ||
| int Check_() EXCLUSIVE_LOCKS_REQUIRED(cs); | ||
| #endif | ||
| EXCLUSIVE_LOCKS_REQUIRED(cs); |
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.
//! Consistency check
- void Check()
- EXCLUSIVE_LOCKS_REQUIRED(cs);
+ void Check() EXCLUSIVE_LOCKS_REQUIRED(cs);Requested in bitcoin#22500 (comment)
lsilva01
left a comment
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 and tested ACK fa4bfef on Ubuntu 20.04. The change simplifies the CAddrMan::Check() code.
|
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. |
theStack
left a comment
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 and code review ACK fa4bfef
Also built locally with #define DEBUG_ADDRMAN set in src/addrman.cpp (the CI result for this PR obviously doesn't have any value, as the modified method CAddrMan::Check() is empty after the pre-processor run)
|
re-ACK fa4bfef have been testing this rebased to current master with DEBUG_ADDRMAN defined could squash |
|
EDIT: removed them again after discussing with Marco. |
|
If If the line 518 ( |
|
Concept ACK |
|
This will make it inconvenient to do something other than For example, it might make sense to do the check right after In general |
Just writing to a log will be easily missed.
The same is done in CTxMemPool::check() and other debug checks for
developers, like lock order debugging.
Can be reviewed with https://en.wikipedia.org/wiki/De_Morgan%27s_laws and
git difftool --tool=meld cccc47b0ef~ cccc47b0ef