Skip to content

Conversation

stickies-v
Copy link
Contributor

@stickies-v stickies-v commented May 7, 2024

This PR:

  • moves warnings from common to the node library and into the node namespace (as suggested in rpc: return warnings as an array instead of just a single one #29845 (comment))
  • generalizes the warnings interface to Warnings::Set() and Warnings::Unset() methods, instead of having a separate function and globals for each warning. As a result, this simplifies the kernel::Notifications interface.
  • removes warnings.cpp from the kernel library
  • removes warning globals
  • adds testing for the warning logic

Behaviour change introduced:

  • the -alertnotify command is executed for all KernelNotifications::warningSet calls, which now also covers the LARGE_WORK_INVALID_CHAIN warning
  • the GUI is updated automatically whenever a warning is (un)set, covering some code paths where it previously wouldn't be, e.g. when node::AbortNode() is called, or for the LARGE_WORK_INVALID_CHAIN warning

Some discussion points:

  • is const std::string& id the best way to refer to warnings? Enums are an obvious alternative, but since we need to define warnings across libraries, strings seem like a straightforward solution. edit: updated approach to use node::Warning and kernel::Warning enums.

@DrahtBot
Copy link
Contributor

DrahtBot commented May 7, 2024

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

Code Coverage

For detailed information about the code coverage, see the test coverage report.

Reviews

See the guideline for information on the review process.

Type Reviewers
ACK ryanofsky, TheCharlatan, achow101

If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update.

Conflicts

Reviewers, this pull request conflicts with the following ones:

  • #30272 (doc: use TRUC instead of v3 and add release note by glozow)
  • #30141 (kernel: De-globalize validation caches by TheCharlatan)
  • #30110 (refactor: TxDownloadManager by glozow)
  • #29641 (scripted-diff: Use LogInfo/LogDebug over LogPrintf/LogPrint by maflcko)

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.

@DrahtBot
Copy link
Contributor

DrahtBot commented May 7, 2024

🚧 At least one of the CI tasks failed. Make sure to run all tests locally, according to the
documentation.

Possibly this is due to a silent merge conflict (the changes in this pull request being
incompatible with the current code in the target branch). If so, make sure to rebase on the latest
commit of the target branch.

Leave a comment here, if you need help tracking down a confusing failure.

Debug: https://github.com/bitcoin/bitcoin/runs/24704508399

@TheCharlatan
Copy link
Contributor

Concept ACK on removing the warnings globals.

@stickies-v stickies-v force-pushed the 2024-04/move-warnings-node branch 2 times, most recently from 3b2b72f to 445e6de Compare May 8, 2024 20:05
@stickies-v
Copy link
Contributor Author

Force-pushed to address compilation failure on non-macOS systems:

  • moved GetNodeWarnings() (in rpc/util.cpp) to node::GetWarningsForRpc() (in node/warnings.cpp). Since rpc/util.cpp is in common, this causes issues after warnings are moved to node. I don't love this approach, but it seemed like the least bad one - open to suggestions if anyone has any?
  • updated bitcoin-chainstate.cpp to the new kernel::Notifications interface

@DrahtBot DrahtBot removed the CI failed label May 8, 2024
Copy link
Contributor

@ryanofsky ryanofsky left a comment

Choose a reason for hiding this comment

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

Code review ACK 445e6de. It was a little unclear in some places what behavior was supposed to be changing, and I think that could be documented better. But overall the changes look good and seem very positive.

@DrahtBot DrahtBot requested a review from TheCharlatan May 23, 2024 17:10
@stickies-v stickies-v force-pushed the 2024-04/move-warnings-node branch from 445e6de to 674da14 Compare May 23, 2024 20:52
@stickies-v stickies-v force-pushed the 2024-04/move-warnings-node branch from 674da14 to 5dfbc35 Compare May 23, 2024 21:11
Copy link
Contributor Author

@stickies-v stickies-v left a comment

Choose a reason for hiding this comment

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

Thank you for the review, @TheCharlatan and @ryanofsky .

In this force push, I've:

  • rebased to address merge conflict from #30115
  • incorporated @TheCharlatan's suggestion to use enum class instead of std::string for the warning identifiers
  • addressed @ryanofsky's comments:
    • improved commit messages to describe the introduced behaviour change and improved a couple of docstrings
    • added release notes to describe the new -alertnotify behaviour
    • updated the Warnings::Set() signature to pass by value and use move semantics
  • removed an unnecessary include in kernel/warning.h

@DrahtBot
Copy link
Contributor

🚧 At least one of the CI tasks failed. Make sure to run all tests locally, according to the
documentation.

Possibly this is due to a silent merge conflict (the changes in this pull request being
incompatible with the current code in the target branch). If so, make sure to rebase on the latest
commit of the target branch.

Leave a comment here, if you need help tracking down a confusing failure.

Debug: https://github.com/bitcoin/bitcoin/runs/25352180163

@stickies-v stickies-v force-pushed the 2024-04/move-warnings-node branch from 5dfbc35 to 66d4f31 Compare May 24, 2024 08:28
@stickies-v stickies-v force-pushed the 2024-04/move-warnings-node branch from 468cf53 to 4ca48b3 Compare June 12, 2024 10:30
@stickies-v
Copy link
Contributor Author

Force pushed to:

Copy link
Contributor

@ryanofsky ryanofsky left a comment

Choose a reason for hiding this comment

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

Code review ACK 4ca48b3. Just rebase and a change to internal commits (removing DoWarning earlier) since last review.

@DrahtBot DrahtBot requested a review from TheCharlatan June 12, 2024 14:20
Copy link
Contributor

@TheCharlatan TheCharlatan left a comment

Choose a reason for hiding this comment

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

Re-ACK 4ca48b3

Since rpc/util.cpp is in common, also move GetNodeWarnings() to
node::GetWarningsForRPC()
Instead of having separate warning functions (and globals) for each
different warning that can be raised, encapsulate this logic into
a single class and allow to (un)set any number of warnings.

Introduces behaviour change:
- the `-alertnotify` command is executed for all
  `KernelNotifications::warningSet` calls, which now also covers the
  `LARGE_WORK_INVALID_CHAIN` warning.
- previously, warnings were returned based on a predetermined order,
  e.g. with the "pre-release test build" warning always first. This
  is no longer the case, and Warnings::GetMessages() will return
  messages sorted by the id of the warning.

Removes warnings.cpp from kernel.
This commit introduces slight behaviour change. Previously, the
GUI status bar would be updated for most warnings, namely
UNKNOWN_NEW_RULES_ACTIVATED, CLOCK_OUT_OF_SYNC and
PRE_RELEASE_TEST_BUILD, but not for LARGE_WORK_INVALID_CHAIN
(and not for FATAL_INTERNAL_ERROR, but that is not really
meaningful).

Fix this by always updating the status bar when the warnings are
changed.
@stickies-v stickies-v force-pushed the 2024-04/move-warnings-node branch from 4ca48b3 to 260f8da Compare June 13, 2024 10:22
@stickies-v
Copy link
Contributor Author

Force pushed to address merge conflict from #29015, no changes otherwise.

Copy link
Contributor

@ryanofsky ryanofsky left a comment

Choose a reason for hiding this comment

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

Code review ACK 260f8da. Only change since last review was rebasing

Copy link
Contributor

@TheCharlatan TheCharlatan left a comment

Choose a reason for hiding this comment

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

Re-ACK 260f8da

@achow101
Copy link
Member

ACK 260f8da

@achow101 achow101 merged commit ddf2ebd into bitcoin:master Jun 17, 2024
@stickies-v stickies-v deleted the 2024-04/move-warnings-node branch June 18, 2024 11:43
@stickies-v
Copy link
Contributor Author

Note: 9c4b0b7 introduced a double lock bug in bitcoin-qt as described in #30400.

@hebasto
Copy link
Member

hebasto commented Jul 14, 2024

Ported to the CMake-based build system in hebasto#264.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants