Skip to content
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

Encapsulate warnings in generalized node::Warnings and remove globals #30058

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

stickies-v
Copy link
Contributor

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.

@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
Concept ACK TheCharlatan

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:

  • #29432 (Stratum v2 Template Provider (take 3) by Sjors)
  • #29415 (Broadcast own transactions only via short-lived Tor or I2P connections by vasild)
  • #29039 (versionbits refactoring by ajtowns)
  • #28830 ([refactor] Check CTxMemPool options in ctor by TheCharlatan)

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.

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 a any number of warnings based
on a (non-enforced) unique id string.

Introduces behaviour change: the `-alertnotify` command is
executed for all `KernelNotifications::warningSet` calls, which
now also covers the `large-work-invalid-chain` warning

Removes warnings.cpp from kernel
@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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants