log: move CreateNewBlock() log line behind a new mining category #36336

pull ismaelsadeeq wants to merge 2 commits into bitcoin:master from ismaelsadeeq:09-2026-mining-log-category changing 4 files +11 −1
  1. ismaelsadeeq commented at 3:27 PM on September 25, 2026: member

    Fixes #36334

    The "CreateNewBlock(): block weight: ..." line was logged unconditionally and could not be turned off, filling the debug log when block templates are built frequently.

    Move it behind a new "mining" logging category, enabled with -debug=mining.

  2. DrahtBot added the label Utils/log/libs on Sep 25, 2026
  3. DrahtBot commented at 3:27 PM on September 25, 2026: contributor

    <!--e57a25ab6845829454e8d69fc972939a-->

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

    <!--006a51241073e994b41acfe9ec718e94-->

    Code Coverage & Benchmarks

    For details see: https://corecheck.dev/bitcoin/bitcoin/pulls/36336.

    <!--021abf342d371248e50ceaed478a90ca-->

    Reviews

    See the guideline and AI policy for information on the review process.

    Type Reviewers
    ACK w0xlt, l0rinc, achow101
    Concept ACK sedited
    Stale ACK willcl-ark, Sjors

    If your review is incorrectly listed, please copy-paste <code>&lt;!--meta-tag:bot-skip--&gt;</code> into the comment that the bot should ignore.

    <!--5faf32d7da4f0f540f40219e4f7537a3-->

  4. sedited commented at 3:32 PM on September 25, 2026: contributor

    Concept ACK

  5. in test/functional/mining_basic.py:427 in e7d91c2034 outdated
     423 | @@ -424,6 +424,12 @@ def test_height_in_locktime(self):
     424 |          assert_equal(block["tx"][0]["locktime"], block["height"] - 1)
     425 |          assert_equal(block["tx"][0]["vin"][0]["sequence"], MAX_SEQUENCE_NONFINAL)
     426 |  
     427 | +    def test_mining_log_category(self):
    


    l0rinc commented at 6:51 PM on September 25, 2026:

    I don't think this is useful, it's not the same abstraction level as test_murch_zawy_mintime and test_pruning and test_height_in_locktime


    ismaelsadeeq commented at 9:48 AM on September 28, 2026:

    Not sure what the suggestion is here, based on the current state of the PR, the test tests a feature added by the PR and fails after running without the production code. AFAICT, it belongs in that file because tests of the same caliber are there as well, like blockmintxfee_parameter etc.


    l0rinc commented at 5:14 PM on September 28, 2026:

    A manual reproducer could be simpler, tests also have a maintenance burden, this seems like a one-off change that we don't need to test on every build, just on the transition (i.e. this PR). Not a blocker.


    stickies-v commented at 12:33 PM on September 29, 2026:

    this seems like a one-off change that we don't need to test on every build, just on the transition

    I agree. These kinds of tests feel incredibly noisy to me, don't add anything meaningful, and are much costlier to remove than they are to add.


    Sjors commented at 4:32 PM on September 29, 2026:

    I guess the question is whether we want to have a functional test for every log message?


    ismaelsadeeq commented at 5:32 PM on September 29, 2026:

    I removed the tests. Thanks for the review.

  6. in src/logging/categories.h:48 in e7d91c2034 outdated
      44 | @@ -45,6 +45,7 @@ enum LogFlags : CategoryMask {
      45 |      TXPACKAGES = (CategoryMask{1} << 27),
      46 |      KERNEL = (CategoryMask{1} << 28),
      47 |      PRIVBROADCAST = (CategoryMask{1} << 29),
      48 | +    MINING = (CategoryMask{1} << 30),
    


    l0rinc commented at 6:57 PM on September 25, 2026:

    Adding a whole new log category for a single debug line seems excessive, could we put this behind an existing close-enough category instead? Mempool seems like the natural home: this line is reporting what got pulled from the mempool into the template, and anyone debugging fee/tx-selection issues already runs -debug=mempool. We can add a new category when the examples demonstrate a need.


    ismaelsadeeq commented at 9:52 AM on September 28, 2026:

    This was discussed in the issue #36334 in comparison with other alternatives, which aren't ideal. I think using the mempool category for mining code here is incorrect.

    New logs will likely be added in the future; see project #33758.


    Sjors commented at 10:09 AM on September 28, 2026:

    I think having a dedicated mining log category makes sense. Putting this message in the mempool category would be confusing for miners, and also impractical because mempool is extremely noisy.


    l0rinc commented at 5:14 PM on September 28, 2026:

    If others are okay with it since we expect to have more coming, I don't mind, please resolve

  7. l0rinc changes_requested
  8. l0rinc commented at 6:58 PM on September 25, 2026: contributor

    Concept ACK, but approach seems excessive

  9. ismaelsadeeq commented at 9:52 AM on September 28, 2026: member
  10. Sjors commented at 10:11 AM on September 28, 2026: member

    Needs a release note that recommends getblocktemplate and Mining IPC users enable this category.

  11. ismaelsadeeq force-pushed on Sep 28, 2026
  12. ismaelsadeeq commented at 11:32 AM on September 28, 2026: member

    Needs a release note that recommends getblocktemplate and Mining IPC users enable this category.

    Done.

  13. willcl-ark commented at 1:11 PM on September 28, 2026: member

    Concept ACK

    I did a search of github and google for "CreateNewBlock(): block weight: to try and find any other projects which bight be relying on parsing this log line, but didn't find anything noteworthy (except someone trying to suppress it).

    I think adding a new category seems fine and on balance probably appropriate here; I get why it might appear overkill too though (it's only one log line), but I agree it doesn't really fit into mempool, validation, estimatefee or any other current category neatly.

    Not strong opinion on the value of the test.

  14. willcl-ark approved
  15. willcl-ark commented at 1:16 PM on September 28, 2026: member

    ACK 7a2c89e1923682e81184b7908a793033c3bd3312

    happy with this change both with or without test.

  16. DrahtBot requested review from l0rinc on Sep 28, 2026
  17. DrahtBot requested review from sedited on Sep 28, 2026
  18. Sjors commented at 1:42 PM on September 28, 2026: member

    ACK 7a2c89e1923682e81184b7908a793033c3bd3312

  19. l0rinc approved
  20. l0rinc commented at 5:16 PM on September 28, 2026: contributor

    ACK 7a2c89e1923682e81184b7908a793033c3bd3312

    While I don't see why a debug log line needs release notes and new category and tests, other reviewers seem to agree with it so I won't block

  21. log: move CreateNewBlock() log line behind a new mining category 54b8795121
  22. doc: add release notes df3008418c
  23. ismaelsadeeq force-pushed on Sep 29, 2026
  24. w0xlt commented at 6:21 PM on September 29, 2026: contributor

    ACK df3008418c20f7eb23736b893c2b997db93ce433

  25. DrahtBot requested review from willcl-ark on Sep 29, 2026
  26. DrahtBot requested review from Sjors on Sep 29, 2026
  27. DrahtBot requested review from l0rinc on Sep 29, 2026
  28. l0rinc commented at 7:47 PM on September 29, 2026: contributor

    diff and code review reACK df3008418c20f7eb23736b893c2b997db93ce433

  29. achow101 commented at 9:18 PM on September 29, 2026: member

    ACK df3008418c20f7eb23736b893c2b997db93ce433

  30. achow101 merged this on Sep 29, 2026
  31. achow101 closed this on Sep 29, 2026

  32. ismaelsadeeq deleted the branch on Sep 30, 2026
  33. fanquake commented at 9:31 AM on September 30, 2026: member

    Backported 54b8795121d3081019befd8a2bc70adcd06fcb65 to 32.x in #36300. Any relevant release notes can be added directly to the wiki.

  34. fanquake referenced this in commit 18765f6734 on Sep 30, 2026
  35. fanquake referenced this in commit 5ac9f35735 on Oct 1, 2026
  36. ismaelsadeeq commented at 4:28 PM on October 1, 2026: member

    Backported 54b8795 to 32.x in #36300. Any relevant release notes can be added directly to the wiki.

    Done, with respect to this and #36365. @janb84, I think the testing guide should also be adjusted?


github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-10-19 03:51 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me