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

Correctly limit overview transaction list #704

Merged

Conversation

john-moffett
Copy link
Contributor

Fixes #703

The way the main overview page limits the number of transactions displayed (currently 5) is not an appropriate use of Qt. Our subclassed transaction sort/filter proxy model returns a maximum of 5 in rowCount(). However, the model itself actually may hold significantly more. While this has worked, it breaks the contract of rowCount().

If bitcoin-qt is run with a DEBUG build of Qt, it'll result in an assert-crash in certain relatively common situations (see #703 for details). Instead of artificially limiting the rowCount() in the subclassed filter, we can hide/unhide the rows in the displaying QListView upon any changes in the sorted proxy filter.

I loaded a wallet with 20,000 transactions and did not notice any performance differences between master and this branch.

For reference, this is the list I'm referring to:

image

The way that the main overview page limits the number
of transactions displayed (currently 5) is not
an appropriate use of Qt. If it's run with a DEBUG
build of Qt, it'll result in a segfault in certain
relatively common situations. Instead of artificially
limiting the rowCount() in the subclassed proxy
filter, we hide/unhide the rows in the displaying
QListView upon any changes in the sorted proxy filter.
@DrahtBot
Copy link
Contributor

DrahtBot commented Jan 26, 2023

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 Sjors, hebasto

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

@jarolrod jarolrod added Bug Something isn't working UI All about "look and feel" labels Jan 27, 2023
@Sjors
Copy link
Member

Sjors commented Feb 1, 2023

tACK 08209c0

@Sjors Sjors requested a review from hebasto February 1, 2023 18:52
@hebasto
Copy link
Member

hebasto commented Feb 1, 2023

Concept ACK.

Comment on lines +309 to +311
for (int i = 0; i < filter->rowCount(); ++i) {
ui->listTransactions->setRowHidden(i, i >= NUM_ITEMS);
}
Copy link
Member

Choose a reason for hiding this comment

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

Could this cause any performance issues with 100K+ txs wallets?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I loaded a wallet with 30K txs and ran a time profiler. This call took approximately 3 milliseconds:

image

The vast majority of time was consumed by re-running the filter and converting to QDateTime (both already existing behavior and unrelated to this PR):

image

Qualitatively, I didn't notice any difference at all.

I'm happy to generate a bunch more transactions overnight and report back tomorrow.

Copy link
Member

@hebasto hebasto left a comment

Choose a reason for hiding this comment

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

Tested 08209c0 ob Ubuntu 22.04. It fixes #703 for me.

Still reviewing.

Copy link
Member

@hebasto hebasto left a comment

Choose a reason for hiding this comment

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

ACK 08209c0, tested on Ubuntu 22.04.

@hebasto hebasto added this to the 24.1 milestone Feb 2, 2023
@hebasto hebasto merged commit 526f67a into bitcoin-core:master Feb 2, 2023
@fanquake
Copy link
Member

fanquake commented Feb 2, 2023

Added to bitcoin/bitcoin#26878 for backporting to 24.x.

fanquake pushed a commit to fanquake/bitcoin that referenced this pull request Feb 2, 2023
The way that the main overview page limits the number
of transactions displayed (currently 5) is not
an appropriate use of Qt. If it's run with a DEBUG
build of Qt, it'll result in a segfault in certain
relatively common situations. Instead of artificially
limiting the rowCount() in the subclassed proxy
filter, we hide/unhide the rows in the displaying
QListView upon any changes in the sorted proxy filter.

Github-Pull: bitcoin-core/gui/pull/704
Rebased-From: 08209c0
sidhujag pushed a commit to syscoin/syscoin that referenced this pull request Feb 3, 2023
08209c0 Correctly limit overview transaction list (John Moffett)

Pull request description:

  Fixes bitcoin#703

  The way the main overview page limits the number of transactions displayed (currently 5) is not an appropriate use of Qt. Our subclassed transaction sort/filter proxy model returns a maximum of `5` in `rowCount()`. However, the model itself actually may hold significantly more. While this has _worked_, it breaks the contract of `rowCount()`.

  If `bitcoin-qt` is run with a DEBUG build of Qt, it'll result in an assert-crash in certain relatively common situations (see bitcoin#703 for details). Instead of artificially limiting the `rowCount()` in the subclassed filter, we can hide/unhide the rows in the displaying `QListView` upon any changes in the sorted proxy filter.

  I loaded a wallet with 20,000 transactions and did not notice any performance differences between master and this branch.

  For reference, this is the list I'm referring to:

  <img width="934" alt="image" src="https://user-images.githubusercontent.com/116917595/214947304-3f289380-3510-487b-80e8-d19428cf2f0f.png">

ACKs for top commit:
  Sjors:
    tACK 08209c0
  hebasto:
    ACK 08209c0, tested on Ubuntu 22.04.

Tree-SHA512: c2a7b1a2a6e6ff30694830d7c722274c4c47494a81ce9ef25f8e5587c24871b02343969f4437507693d4fd40ba7a212702b159cf54b3357d8d76c02bc8245113
fanquake pushed a commit to fanquake/bitcoin that referenced this pull request Feb 22, 2023
The way that the main overview page limits the number
of transactions displayed (currently 5) is not
an appropriate use of Qt. If it's run with a DEBUG
build of Qt, it'll result in a segfault in certain
relatively common situations. Instead of artificially
limiting the rowCount() in the subclassed proxy
filter, we hide/unhide the rows in the displaying
QListView upon any changes in the sorted proxy filter.

Github-Pull: bitcoin-core/gui/pull/704
Rebased-From: 08209c0
glozow added a commit to bitcoin/bitcoin that referenced this pull request Feb 27, 2023
784a754 wallet, rpc: Update migratewallet help text for encrypted wallets (Andrew Chow)
debcfe3 tests: Tests for migrating wallets by name, and providing passphrase (Andrew Chow)
ccc72fe wallet: Be able to unlock the wallet for migration (Andrew Chow)
50dd8b1 rpc: Allow users to specify wallet name for migratewallet (Andrew Chow)
648b062 wallet: Allow MigrateLegacyToDescriptor to take a wallet name (Andrew Chow)
ab3bd45 i2p: use consistent number of tunnels with i2pd and Java I2P (Vasil Dimov)
29cdf42 i2p: lower the number of tunnels for transient sessions (Vasil Dimov)
5027e93 i2p: reuse created I2P sessions if not used (Vasil Dimov)
a62c541 wallet: reuse change dest when recreating TX with avoidpartialspends (Matthew Zipkin)
64e7db6 Zero out wallet master key upon lock (John Moffett)
b7e242e Correctly limit overview transaction list (John Moffett)
cff6718 depends: fix systemtap download URL (fanquake)
7cf73df Add missing includes to fix gcc-13 compile error (MarcoFalke)
07397cd addrdb: Only call Serialize() once (Martin Zumsande)
91f83db hash: add HashedSourceWriter (Martin Zumsande)
5c824ac For feebump, ignore abandoned descendant spends (John Moffett)
428dcd5 wallet: Skip rescanning if wallet is more recent than tip (Andrew Chow)
cbcdafa test: wallet: check that labels are migrated to watchonly wallet (Sebastian Falbesoner)
342abfb wallet: fully migrate address book entries for watchonly/solvable wallets (Sebastian Falbesoner)

Pull request description:

  Backports:
  * #26595
  * #26675
  * #26679
  * #26761
  * #26837
  * #26909
  * #26924
  * #26944
  * bitcoin-core/gui#704
  * #27053
  * #27080

ACKs for top commit:
  instagibbs:
    ACK 784a754
  achow101:
    ACK 784a754
  hebasto:
    ACK 784a754, I've made backporting locally and got a diff between my branch and this PR as follows:

Tree-SHA512: 8ea84aa02d7907ff1e202e1302b441ce9ed2198bf383620ad40056a5d7e8ea88e1047abef0b92d85648016bf9b3195c974be3806ccebd85bef4f85c326869e43
@bitcoin-core bitcoin-core locked and limited conversation to collaborators Feb 2, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug Something isn't working UI All about "look and feel"
Projects
None yet
Development

Successfully merging this pull request may close these issues.

assert: "last < rowCount(parent)" in qabstractitemmodel.cpp
6 participants