Join GitHub today
GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
[qt] Add abstraction layer for accessing node and wallet functionality from gui #10244
Conversation
ryanofsky
referenced
this pull request
Apr 20, 2017
Open
bitcoin-qt: spawn bitcoind and communicate over pipe (Experimental, WIP, Depends on #10244) #10102
|
ClientModel and WalletModel were already meant as abstraction layer for accessing the core from the GUI. What is your rationale for adding another layer? |
ClientModel and WalletModel might have been intended to be an abstraction layer, but they are not functioning like one. There are libbitcoin functions and global variables accessed all over Qt code right now. With this change, all of these calls (there are around 200 of them) are stripped out of Qt code and moved into a one file: src/ipc/local/interfaces.cpp. |
|
I once did a similar thing,.. but stopped at some point and now I know why. I also agree with @laanwj that the clientmodel (node) and the walletmodal (wallet) are originally though to be that layer. What would be the downsides of using the exiting layers (clientmodel / walletmodel) better? |
jonasschnelli
added the
GUI
label
Apr 20, 2017
If you look at the Also, and in more concrete terms, the reason these interfaces live outside the src/qt directory is that with #10102, they need to be accessed not only by |
|
The general IPC interface makes sense to me. The main problem I see for any type of low latency IPC/RPC is the missing asynchronity. |
Not sure if you saw the comments about this in the other pr starting here: #10102 (comment) These changes are orthogonal to event processing / blocking issues in the UI. If UI blocked before, it will still block after these changes, if UI didn't block before, it won't start blocking now because of these changes. If remote calls are too slow because of socket/serialization overhead, we can process UI events in the background while they are being made. There are many ways to accomplish this, with one possible way described in that comment above. If anything, having calls get funnelled through an IPC framework makes it easier, not harder to add more asynchronicity. |
|
Also would point out that Node and Wallet interfaces in ipc/interfaces.h were mainly designed with goal of changing existing Qt code as little as possible. They aren't in any way set in stone, and I would expect them to evolve over time. Probably some calls will get consolidated, others will get broken up, calls that currently return big chunks of data will be made streaming, etc. |
|
Thinking again and discussing this with @sipa / @laanwj, I think we should use the existing client-/walletmodal as node/wallet abstraction (including a possible IPC abstraction). What's missing in the first place are better asynchronous messaging between the GUI and the wallet/node. IMO using a thread with queue for general node/wallet communication (and eventual additional threads for procedures that usually take longer) seems after a low hanging fruit with direct benefits. Using QT slots/signals for all(most?) communication would be required anyways and would be beneficial even without IPC and therefor should be done first. |
Again I think this is (and should be) an independent issue, but if you want to flesh out some more concrete suggestions and I would be happy to hear them.
This is exactly what the change I was suggesting in #10102 (comment) does. |
This was my point too. Making the GUI asynchronous would avoid ever hard-freezing the GUI. Modern operating systems assume that an application has crashed if its GUI thread is unresponsive. This is a priority for improving user experience. For example: Currently, if e.g. a transaction is sent while the cs_main lock is held the entire thing hangs for a moment. Ideally it would display a modal dialog with a status, or progress animation instead. There are similar issues at startup. Sure, this is only partially related to IPC work: When the GUI already would communicate with Qt signals and slots with the core backend (similar to how RPCConsole and RPCThread communicate, for example), it could be mostly oblivious whether this backend exists in-process or communicates over a pipe. Although it's laudable that you're working on this, it looks to me that what you are doing currently is simply replicating what we do now but replacing direct core calls with IPC calls. The drawback is that it calcifies some things that shouldn't have been designed that way in the first place (e.g. into multiple abstraction layers), making it harder to improve later. |
Could you be more concrete about this? I don't see how it is true. Direct calls before are still direct calls now. If we want to follow the RPCConsole / RPCExecutor model in other parts of Qt code, I don't see how any of the changes I've made for IPC make this more difficult. |
|
I had a look at discussion in IRC (https://botbot.me/freenode/bitcoin-core-dev/msg/84348426/) With respect, what I think you guys are missing on the However, I do see that it is kind of silly to have cases where Qt code calls a Also, if this PR will be too difficult to review because of its size (https://botbot.me/freenode/bitcoin-core-dev/msg/84348447/), I can easily decompose it into smaller PRs that could be gradually merged. It is already broken up into separate commits, and many of the individual commits could be further broken up (right now they try to group together related changes). |
This was referenced May 4, 2017
|
@laanwj and @jonasschnelli can you let me know if you still see issues with this approach? On the Qt model class issue, I pulled out a bunch of model methods that were just wrapping IPC calls so it should be clearer what actual work walletmodel.cpp and clientmodel.cpp are doing. I also added a little blurb to the IPC README describing what the distinction between Qt model classes and the IPC interface classes is supposed to be. On the asynchronous GUI issue, I created #10504 for more discussion, but think that issue is mostly unrelated to the changes in this PR, except as far as some changes here might potentially make it easier to identify blocking calls and make them asynchronous. |
laanwj
added
to Blockers in High-priority for review
Jun 1, 2017
|
Concept ACK on the approach, moving things to interfaces instead of global calls is usually good as it makes it easier to see what the interface to the core is. |
|
Concept ACK. |
ryanofsky
added some commits
Mar 27, 2017
ryanofsky
added a commit
to ryanofsky/bitcoin
that referenced
this pull request
Jun 15, 2017
|
|
ryanofsky |
e7280bf
|
This was referenced Jun 15, 2017
ryanofsky
added a commit
to ryanofsky/bitcoin
that referenced
this pull request
Jun 15, 2017
|
|
ryanofsky |
3a43bb9
|
laanwj
removed
from Blockers in High-priority for review
Jul 11, 2017
ryanofsky
added a commit
to ryanofsky/bitcoin
that referenced
this pull request
Jul 11, 2017
|
|
ryanofsky |
30d2100
|
ryanofsky commentedApr 20, 2017
•
edited
This is based on #10600. The non-base commits are listed below.
This change:
Node&Walletinterfaces in src/ipc/interfaces.h with implementations in src/ipc/local/interfaces.cppThis change allows followup PR #10102 (makes
bitcoin-qtcontrolbitcoindover an IPC socket) to work without any significant updates to Qt code (the only change in Qt code there is ryanofsky/bitcoin@ab0afba#diff-8c9d79ba40bf702f01685008550ac100 which switches the Qt IPC protocol fromLOCALtoCAPNP)Other benefits of this change:
Other notes:
This is based on #10600. The non-base commits are:
d81553869eRemove direct bitcoin calls from qt/bitcoin.cppf15c66668dRemove direct bitcoin calls from qt/optionsmodel.cppde1c51a4c5Remove direct bitcoin calls from qt/bitcoingui.cppbf5402d478Remove direct bitcoin calls from qt/utilitydialog.cppdfa9f2c66eRemove direct bitcoin calls from qt/splashscreen.cpp027e602555Remove direct bitcoin calls from qt/clientmodel.cpp8d848cb63eRemove direct bitcoin calls from qt/intro.cpp54e9432a56Remove direct bitcoin calls from qt/peertablemodel.cppc08ce5bbfcRemove direct bitcoin calls from qt/bantablemodel.cppfec4a06f04Remove direct bitcoin calls from qt/rpcconsole.cpp6a5652d604Remove direct bitcoin calls from qt/optionsdialog.cpp8ef6f040f4Remove most direct bitcoin calls from qt/walletmodel.cppb5887682f9Remove direct bitcoin calls from qt/coincontroldialog.cppc6461dc72dRemove direct bitcoin calls from qt/addresstablemodel.cpp250293f015Remove direct bitcoin calls from qt/paymentserver.cppae06c3a2abRemove direct bitcoin calls from qt transaction table filesc1fbdd5ca9Remove direct bitcoin access from qt/guiutil.cpp7b91ed1757Remove direct bitcoin calls from qt/sendcoinsdialog.cpp5e49ef7b42Add src/ipc/README.md