-
Notifications
You must be signed in to change notification settings - Fork 37.7k
qt: Use SynchronizationState enum for signals to GUI #18152
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
qt: Use SynchronizationState enum for signals to GUI #18152
Conversation
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. ConflictsReviewers, this pull request conflicts with the following ones:
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See comments below, but some parts of this change seem buggy, or I'm not understanding them.
In my comments from #18121, I was trying to suggest having the node tell the gui its state, instead of having the gui query the node. I think it's better for the node to just tell the GUI its state, instead of having the GUI piece together information and make assumptions. Here's what I was suggesting: c97298a (branch). Feel free to use these changes
f52bafc
to
7a2a5ed
Compare
@ryanofsky Also rebased due to #17399. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code review ACK 7a2a5ed. This looks great! Sorry I missed the previous update. I really like the way the PR is broken up now and dropping unused arguments.
A followup to this PR would be able to remove ClientModel::getBlockSource too, but it's good to postpone that since this PR is already changing a number of things
src/util/system.h
Outdated
enum class SynchronizationState { | ||
INIT_DOWNLOAD, | ||
INIT_REINDEX, | ||
POST_INIT | ||
}; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In commit "refactor: Pass SynchronizationState enum to GUI" (ebc93a0)
I think it probably doesn't make sense to have this in system.h, which mostly contains lower level operating system stuff. I'd probably move it to validation.h here
Line 105 in dc5333d
src/util/validation.h
header (which existed previously but was recently deleted)
Could also add a descriptive comment for the enum like /** Current sync state passed to tip changed callbacks. */.
Could also reorder enum to reflect order the states occur: Reindex -> Download -> Post-Init
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Co-authored-by: Russell Yanofsky <russ@yanofsky.org>
7a2a5ed
to
a0d0f1c
Compare
Updated 7a2a5ed -> a0d0f1c (pr18152.03 -> pr18152.04, diff):
|
{ | ||
// Disabling macOS App Nap on initial sync, disk and reindex operations. | ||
#ifdef Q_OS_MAC | ||
(m_node.isInitialBlockDownload() || m_node.getReindex() || m_node.getImporting()) ? m_app_nap_inhibitor->disableAppNap() : m_app_nap_inhibitor->enableAppNap(); | ||
if (sync_state == SynchronizationState::POST_INIT) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We drop the check on fImporting
here? Is that a problem?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the (m_node.isInitialBlockDownload() || m_node.getReindex() || m_node.getImporting())
expression all but the first operand are redundant as in CChainState::IsInitialBlockDownload()
we have:
Lines 1302 to 1303 in 362f9c6
if (fImporting || fReindex) | |
return true; |
Right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see. It was unnecessary in the first place as it looks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code review ACK a0d0f1c. Only changes since last review were rebase and tweaking SynchronizationState enum declaration as suggested (thanks!)
I'm not opposed to backport this since the Mac-Only GUI freeze is IMO an ugly bug. |
Code review ACK a0d0f1c. |
…k hash. a06e845 BlockTip struct created and connected to notifyHeaderTip and notifyBlockTip signals. (furszy) 2f86720 Added best block hash to the NotifyHeaderTip and NotifyBlockTip signals. (furszy) Pull request description: Rationale: The height based polling in the GUI is an issue on chain reorgs. Any new tip signal with the same height as the one that it's cached in the model was not triggering the GUI update (interpreting it as the same same block when it could receive a different one). Ending up with bad information presented in the GUI. This PR essentially changes the last cached height to be a last cached block hash. --- Old historical information of this PR. As the tip height is cached and updated via signaling in clientModel, there is no need to continue locking `cs_main` on every balance poll (`m_node.getNumBlocks()` method call). Extra topic: Would suggest to change the `cachedNumBlocks` field inside `walletModel` to a more understandable name, maybe `nLastBalanceUpdateHeight`. And finally, this will have the equal height reorg issue mentioned [here](#17905 (comment)), whatever is presented to fix it, this should use the same flow too. **[Edit - 24/01/2020]** Have added #[17905](#17905 (comment)) comment fix here too. ACKs for top commit: jonasschnelli: utACK a06e845 - it would be great to have QT unit tests (in this case for a reorg) that either automatically inspect the window content based on accessibility and tests for expected values or at least allow for quick manual re-testing (screenshots, automatically create UI situations). hebasto: re-ACK a06e845, suggested style changes implemented since the [previous](#17993 (review)) review. ryanofsky: Code review ACK a06e845. A lot of changes since the last review: rebase after sync_state introduction #18152 and tryGetBalances revert #18587, reverting getLastBlockTime change, fixing spacing and initializations and renaming some variables Tree-SHA512: 835e587a8296df9899cccd7b3e598a5970942b640e432e6a32de0b4eaea5b40f9271258f089ec033595311707b74a0f7187ecf8ed397c713e1153e2714072975
…st block hash. a06e845 BlockTip struct created and connected to notifyHeaderTip and notifyBlockTip signals. (furszy) 2f86720 Added best block hash to the NotifyHeaderTip and NotifyBlockTip signals. (furszy) Pull request description: Rationale: The height based polling in the GUI is an issue on chain reorgs. Any new tip signal with the same height as the one that it's cached in the model was not triggering the GUI update (interpreting it as the same same block when it could receive a different one). Ending up with bad information presented in the GUI. This PR essentially changes the last cached height to be a last cached block hash. --- Old historical information of this PR. As the tip height is cached and updated via signaling in clientModel, there is no need to continue locking `cs_main` on every balance poll (`m_node.getNumBlocks()` method call). Extra topic: Would suggest to change the `cachedNumBlocks` field inside `walletModel` to a more understandable name, maybe `nLastBalanceUpdateHeight`. And finally, this will have the equal height reorg issue mentioned [here](bitcoin#17905 (comment)), whatever is presented to fix it, this should use the same flow too. **[Edit - 24/01/2020]** Have added #[17905](bitcoin#17905 (comment)) comment fix here too. ACKs for top commit: jonasschnelli: utACK a06e845 - it would be great to have QT unit tests (in this case for a reorg) that either automatically inspect the window content based on accessibility and tests for expected values or at least allow for quick manual re-testing (screenshots, automatically create UI situations). hebasto: re-ACK a06e845, suggested style changes implemented since the [previous](bitcoin#17993 (review)) review. ryanofsky: Code review ACK a06e845. A lot of changes since the last review: rebase after sync_state introduction bitcoin#18152 and tryGetBalances revert bitcoin#18587, reverting getLastBlockTime change, fixing spacing and initializations and renaming some variables Tree-SHA512: 835e587a8296df9899cccd7b3e598a5970942b640e432e6a32de0b4eaea5b40f9271258f089ec033595311707b74a0f7187ecf8ed397c713e1153e2714072975
Summary: ``` This PR is a followup of #18121 and: addresses confusion about GUI notification throttling conditions removes isInitialBlockDownload() call from the GUI back to the node (on macOS). ``` Backport of core [[bitcoin/bitcoin#18152 | PR18152]]. Depends on D8334. Test Plan: ninja all check-all Also run the tests on OSX. Reviewers: #bitcoin_abc, PiRK Reviewed By: #bitcoin_abc, PiRK Differential Revision: https://reviews.bitcoinabc.org/D8335
This PR is a followup of #18121 and:
isInitialBlockDownload()
call from the GUI back to the node (on macOS). See: ryanofsky's comment