Skip to content

Conversation

jonatack
Copy link
Member

@jonatack jonatack commented Jul 17, 2021

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

@DrahtBot DrahtBot added the Docs label Jul 17, 2021
@DrahtBot
Copy link
Contributor

DrahtBot commented Jul 19, 2021

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

Conflicts

Reviewers, this pull request conflicts with the following ones:

  • #20233 (addrman: Make consistency checks a runtime option by jnewbery)

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.

Copy link
Member

@jarolrod jarolrod left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:

2021-07-19T04:37:25Z Check addrman
2021-07-19T04:37:25Z ADDRMAN CONSISTENCY CHECK FAILED!!! err=-19

Wonder what other useful information could be logged.

@jonatack
Copy link
Member Author

jonatack commented Jul 19, 2021

Thanks @jarolrod for testing. I've not seen this check fail before; could you describe your config? It's hitting src/addrman.cpp::L524. How many tor and i2p addresses are returned if you run -addrinfo?

@theStack
Copy link
Contributor

Concept ACK

#define DEBUG_ADDRMAN
```

and then build (`make`) and run bitcoind. You can use the `-debug=addrman`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
and then build (`make`) and run bitcoind. You can use the `-debug=addrman`
then build (`make`) and run bitcoind. You can use the `-debug=addrman`

@practicalswift
Copy link
Contributor

cr ACK 68ebaa0

Making this more clear makes sense since one might incorrectly assume that --enable-debug would define DEBUG_ADDRMAN.

@mzumsande
Copy link
Contributor

ACK 68ebaa0

I remember enabling DEBUG_ADDRMAN once as described, but asking myself if I was really supposed to do it this way.

@jonatack
Copy link
Member Author

Updated with @fanquake's suggestion per git range-diff 6499928 68ebaa0 baac29c

@practicalswift
Copy link
Contributor

ACK baac29c

1 similar comment
@mzumsande
Copy link
Contributor

ACK baac29c

Copy link
Contributor

@theStack theStack left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK baac29c

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.

@fanquake
Copy link
Member

fanquake commented Aug 5, 2021

Given it's likely that #20233 is going to be merged shortly, which just removes DEBUG_ADDRMAN, I'm going to close this PR in favour of that change.

@fanquake fanquake closed this Aug 5, 2021
@bitcoin bitcoin deleted a comment from josedanielrojaspixel Aug 5, 2021
@jonatack
Copy link
Member Author

jonatack commented Aug 5, 2021

Oh, I didn't see the two changes as mutually exclusive. I think the logging is still pertinent and was planning to rebase and drop the doc commit if that PR is merged, and perhaps add some follow-ups.

fanquake added a commit that referenced this pull request Aug 13, 2021
a4d7854 [addrman] Make addrman consistency checks a runtime option (John Newbery)
10aac24 [tests] Make deterministic addrman use nKey = 1 (John Newbery)
fa9710f [addrman] Add deterministic argument to CAddrMan ctor (John Newbery)
ee458d8 Add missing const to CAddrMan::Check_() (MarcoFalke)

Pull request description:

  CAddrMan has internal consistency checks. Currently, these are only run when the program is compiled with the  `DEBUG_ADDRMAN` option. This option is not enabled on any of our CI builds, and it's likely that no-one is running them at all.

  This PR makes consistency checks a (hidden) runtime option that can be enabled with `-checkaddrman`, where `-checkaddrman=n` will result in the consistency checks running every n operations (similar to `-checkmempool=n`). We set the ratio to 1/100 for our unit tests, and leave it disabled by default for all networks. Additionally, a consistency check failure now asserts, rather than logging and continuing. This matches the behavior of CTxMemPool and TxRequestTracker, where a failed consistency check asserts.

ACKs for top commit:
  jonatack:
    ACK a4d7854 per `git diff 00fd089 a4d7854`, tested by adding logging similar to #22479 and running with `-checkaddrman=<n>` for various values 0/1/10/100 etc, tested the updated docs with `bitcoind -help-debug | grep -A2 "checkaddrman\|checkmempool"` and verified rebased on master that compiling with `CPPFLAGS="-DDEBUG_ADDRMAN"` no longer causes the build to error.
  mzumsande:
    Code-review ACK a4d7854
  theStack:
    Code-review ACK a4d7854

Tree-SHA512: eaee003f7a99154822c5b5efbc62008d32c1efbecc6fec6e183427f6b2ae5d30b3be7924e3a7271b1a1de91517f5bd2a70011d45358c3105c6a0702f12b70f7c
@jonatack
Copy link
Member Author

Hm, seems I don't have the privileges required to re-open my PR for the logging. Will open a new one, I guess.

@jonatack jonatack deleted the debug-addrman branch August 13, 2021 09:26
@jonatack
Copy link
Member Author

Thanks for the reviews everyone. Feel free to re-ACK in #22696 if you think it is helpful.

fanquake added a commit that referenced this pull request Aug 14, 2021
4844b74 p2p: log addrman consistency checks (Jon Atack)

Pull request description:

  This mini-patch picks up #22479 to log addrman consistency checks in the `BCLOG::ADDRMAN` category when they are enabled with the `-checkaddrman=<n>` configuration option for values of n greater than 0.

  ```
  $ ./src/bitcoind -signet -checkaddrman=20 -debug=addrman
  ...
  2021-08-13T11:14:45Z Addrman checks started: new 3352, tried 89, total 3441
  2021-08-13T11:14:45Z Addrman checks completed successfully
  ```

  This allows people to
  - verify the checks are running
  - see when and how often they are being performed
  - see the number of new/tried/total addrman entries per check
  - see the start/end of the checks

  Thanks to John Newbery for ideas to improve this logging.

ACKs for top commit:
  jnewbery:
    Code review ACK 4844b74
  Zero-1729:
    tACK 4844b74
  theStack:
    Concept and code-review ACK 4844b74 ♟️

Tree-SHA512: 10b51c480d52a753ea8a59dbdd1e2c4f49067e7f4afe59d58426a8fb438f52447fe3a6090fa52132bc382d876927fa338b229c906d85668086f7f8f5bd8ed38a
sidhujag pushed a commit to syscoin/syscoin that referenced this pull request Aug 15, 2021
4844b74 p2p: log addrman consistency checks (Jon Atack)

Pull request description:

  This mini-patch picks up bitcoin#22479 to log addrman consistency checks in the `BCLOG::ADDRMAN` category when they are enabled with the `-checkaddrman=<n>` configuration option for values of n greater than 0.

  ```
  $ ./src/bitcoind -signet -checkaddrman=20 -debug=addrman
  ...
  2021-08-13T11:14:45Z Addrman checks started: new 3352, tried 89, total 3441
  2021-08-13T11:14:45Z Addrman checks completed successfully
  ```

  This allows people to
  - verify the checks are running
  - see when and how often they are being performed
  - see the number of new/tried/total addrman entries per check
  - see the start/end of the checks

  Thanks to John Newbery for ideas to improve this logging.

ACKs for top commit:
  jnewbery:
    Code review ACK 4844b74
  Zero-1729:
    tACK 4844b74
  theStack:
    Concept and code-review ACK 4844b74 ♟️

Tree-SHA512: 10b51c480d52a753ea8a59dbdd1e2c4f49067e7f4afe59d58426a8fb438f52447fe3a6090fa52132bc382d876927fa338b229c906d85668086f7f8f5bd8ed38a
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Aug 18, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants