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

Decouple WalletModel from RPCExecutor #841

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

furszy
Copy link
Member

@furszy furszy commented Oct 4, 2024

A more comprehensive fix for the issue described in #837.

Since the WalletModel class is unavailable when compiling without wallet support
(-DENABLE_WALLET=0), the RPC executor class should not be coupled to it.
This decoupling ensures GUI compatibility with builds that omit wallet support.

This also drops an extra #ifdef ENABLE_WALLET block which is always good.

@DrahtBot
Copy link
Contributor

DrahtBot commented Oct 4, 2024

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

Reviews

See the guideline for information on the review process.

Type Reviewers
ACK pablomartin4btc, BrandonOdiwuor

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:

  • #692 (Debug Console implementation of generate method by hernanmarino)

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
Contributor

@promag promag left a comment

Choose a reason for hiding this comment

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

Concept meh, WalletModel is coupled to RPCConsole, why bother with RPCExecutor?

@hebasto hebasto changed the title gui: bugfix, decouple WalletModel from RPCExecutor bugfix: Decouple WalletModel from RPCExecutor Oct 4, 2024
@furszy
Copy link
Member Author

furszy commented Oct 4, 2024

Concept meh, WalletModel is coupled to RPCConsole, why bother with RPCExecutor?

Thats because the GUI view code and the RPC command parsing and executing functions are entangled right now, but this doesn’t need to remain the case. While the view might require access to the WalletModel for retrieving certain information to display (perhaps more so in the future because we don't do much with it now), the underlying procedures for running the commands don’t depend on it. They only need the wallet name, if it exists, to append the URI to the command and they could be placed on a different file.

@DrahtBot
Copy link
Contributor

DrahtBot commented Oct 4, 2024

🚧 At least one of the CI tasks failed.
Debug: https://github.com/bitcoin-core/gui/runs/31084944010

Hints

Try to run the tests locally, according to the documentation. However, a CI failure may still
happen due to a number of reasons, for example:

  • Possibly 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.

  • A sanitizer issue, which can only be found by compiling with the sanitizer and running the
    affected test.

  • An intermittent issue.

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

@hebasto
Copy link
Member

hebasto commented Oct 4, 2024

@furszy 3f34c04 "gui: bugfix, decouple WalletModel from RPCExecutor"

Maybe remove "bugfix" from the commit message, as there is no reproducible bug in the master branch?

@furszy furszy force-pushed the 2024_gui_rpconsole_walletmodel_dependency branch from 3f34c04 to 770c3a9 Compare October 4, 2024 15:37
@hebasto hebasto changed the title bugfix: Decouple WalletModel from RPCExecutor Decouple WalletModel from RPCExecutor Oct 4, 2024
Since the `WalletModel` class is unavailable when compiling
without wallet support `(-DENABLE_WALLET=0)`, the RPC executor
class should not be coupled to it. This decoupling ensures GUI
compatibility with builds that omit wallet support.
Copy link
Contributor

@pablomartin4btc pablomartin4btc left a comment

Choose a reason for hiding this comment

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

tACK 002b792

Tested the rpc console with and without -DENABLE_WALLET. I think the refactor makes sense as the rpc just needs the wallet name for the related commands.

Out of the scope of this PR, I noticed that the order of the wallets in the combo-boxes corresponds to the settings.json file and if the user changes the wallet in the main window, when the rpc console is open, the wallet in the console combo doesn't correspond with the one in the main window, which is ok if you want to compare data but I think when the console opens it should have the same. Also perhaps we should show the last used wallet (in ./config/Bitcoin-Qt-*.conf?) when qt starts (if still in the loaded wallets in settings.json) instead of showing the first of the list.

@@ -169,7 +169,7 @@ class PeerIdViewDelegate : public QStyledItemDelegate
* @param[out] pstrFilteredOut Command line, filtered to remove any sensitive data
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: describe wallet_name as a param[in] (wallet_model wasn't there either)

Suggested change
* @param[out] pstrFilteredOut Command line, filtered to remove any sensitive data
* @param[out] pstrFilteredOut Command line, filtered to remove any sensitive data
* @param[in] wallet_mame ...

@furszy
Copy link
Member Author

furszy commented Oct 7, 2024

Out of the scope of this PR, I noticed that the order of the wallets in the combo-boxes corresponds to the settings.json file and if the user changes the wallet in the main window, when the rpc console is open, the wallet in the console combo doesn't correspond with the one in the main window, which is ok if you want to compare data but I think when the console opens it should have the same. Also perhaps we should show the last used wallet (in ./config/Bitcoin-Qt-*.conf?) when qt starts (if still in the loaded wallets in settings.json) instead of showing the first of the list.

This surely comes from the fact that the RPC console view is created during initialization. The presentation of the dialog in screen is merely a show() call. So there is no "open for the first time" concept right now.
If the goal is still to move to a new GUI, I wouldn't start changing the views behavior now. The current behavior doesn't seem to be "that" bad anyway.

@pablomartin4btc
Copy link
Contributor

If the goal is still to move to a new GUI, I wouldn't start changing the views behavior now.

Yeah, neither do I, just mentioning it here since I just passed thru while testing.

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.

strong concept ack

Copy link
Contributor

@BrandonOdiwuor BrandonOdiwuor left a comment

Choose a reason for hiding this comment

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

tACK 002b792

Was able to build successfully on Ubuntu 24.04 with Qt version 5.15.13 with -DENABLE_WALLET=OFF and -BUILD_GUI=ON flags and was able to successfully try a couple of RPCs on the GUI RPC console

Screenshot from 2024-11-19 10-10-48

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.

7 participants