Repository navigation
Conversation
The transaction list resolved each row's label through AddressTableModel::labelForAddress, which asked the wallet under a blocking cs_wallet lock. That ran on every repaint of a visible row and on every filter or sort pass over the history, and waited whenever the wallet held its lock, for example for each block it connects. Only during a wallet encryption did it answer from the model's own rows. The transaction table now always answers from the address table model's rows through the new cachedLabelForAddress(), which normalises the address the way the wallet lookup does. The rows match the wallet's labels: they are built from getAddresses(), which lists exactly the non-change entries getAddress() finds, and every address book notification updates them. The other labelForAddress() callers, which are dialog actions, keep reading the wallet, as does purposeForAddress(). Because nothing reads the wallet on repaint any more, an address book change must invalidate the rows that show it. WalletModel:: updateAddressBook() now has the transaction table emit dataChanged for those rows only, so views, label searches and sorts follow the address book whichever of a payment and its label is delivered first. The message signing dialog replaces the address table model with one that lists only legacy addresses. That model now keeps the entries it leaves out of its rows, and keeps them current, so label lookups stay complete whatever model is displayed. Refs #445 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The lock-holding threads in the new label tests gave up after five seconds, and some checks waited five seconds for queued notifications, so a CI runner that stalls the process for several seconds could fail them. The synthetic wallet now wakes the holder as soon as the GUI thread asks it for an address, so that test fails at once without depending on time; the remaining bounds only end a GUI thread that waits for the lock. Queued notifications are delivered directly once the thread that raised them has ended, instead of waiting for them. Refs #445 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review of the first commit found that keeping the entries a pk_hash_only address table model leaves out of its rows in a second list let new non-legacy entries into its rows, left the transaction list reading a model that refresh() swaps out without telling the rows, and kept a full copy of the address book in every model the message signing dialog creates. Instead, the transaction table keeps reading the address table model the wallet model was created with, which lists every address, and WalletModel::updateAddressBook() keeps every address table model it has handed out current. That model is also the one the address book pages show, so they no longer stop following the address book after the message signing dialog has called refresh(). The pk_hash_only model is as before. updateAddressLabel() now collects the rows first and stops emitting if a listener deletes the model or changes its rows. Refs #445 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
WalletModel's constructor built the address table model, which reads the address book, before subscribeToCoreSignals() registered the address book handler, and the transaction history loads in between, which takes seconds for a long history. A change made meanwhile, such as a setlabel or getnewaddress RPC while the wallet opens or a receiving address the wallet files while it syncs, never reached the GUI. The transaction list now shows labels from that model, so it would have kept the stale label until the GUI restarted. Register only the address book handler before the address table model reads the address book. Notifications from other threads are queued and applied after the constructor has returned; one for a change the read already includes is skipped, or applied again with the state the read found. The other handlers are registered where they were. Refs #445 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
WalletModel::updateAddressBook() sent each address book change to every address table model refresh() had ever created. The message signing dialog has refresh() create one each time it opens its address book, and nothing shows the earlier ones, so each change cost more the more often the dialog had been opened, and each legacy-only model logged a warning for every change to another address. Keep the model created with the wallet model in a member and update it and the one getAddressTableModel() currently returns. The member says which model is the complete one, where finding the first child would rely on child order, which Qt leaves undefined for findChild(), and would also find a model that is still reading the address book. A change raised on the GUI thread is delivered at once, so one raised during that read would have been applied there and then read again, listing the address twice. The constructor raises none, but nothing now depends on that. Share the lookup of an address table entry by destination between cachedLabelForAddress() and the encryption-in-progress branch of getAddressData(), and drop a header sentence that did not hold: a pk_hash_only model takes in a new entry for any address, as before. In the label tests, release the lock-holding thread from a scope guard, so a failed check no longer waits out the thread's 60 second bound. Refs #445 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Finding and notifying the transaction rows that show a changed label ran inside the wallet's address book notification. A change made on the GUI thread, such as an edit on the address book page, calls WalletModel::updateAddressBook() directly while the wallet holds cs_wallet, and for a deletion an open database transaction, so the scan over the history and the proxies' re-filtering, which read transaction statuses, ran under that lock. Each notification also made its own pass over the history, and an address shown by many rows sent a signal for every range of its rows, each for every column. The address table models still take a change at once. The transaction table now notes the address and queues a pass, which runs once the event loop is reached and covers every address changed meanwhile, so a burst of K changes over N rows costs one pass of N rows instead of K. The pass sends one dataChanged() for the address column, from the first row that shows a changed label to the last. One signal is not only cheaper: a proxy sorts the rows of a signal again among its other rows, which it takes to be in order, and the labels of all the rows have already changed, so with a signal per range a list sorted by the address column misplaced them. Only the address column shows the label, so a list sorted by date is no longer sorted again; filters still look at every row the signal covers. If a listener adds or removes rows while the signal is delivered, the pass is queued again instead of dropping the rows. Rows whose address is text the wallet stored are compared through the address book key the label lookup uses, against all changed addresses at once. Refs #445 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
cachedLabelForAddress() decodes an address and looks up its encoding. An address that does not decode, or a transaction row without one, became a lookup of the empty string, which an entry whose encoding is empty would answer. The wallet finds no entry for such a destination, so the shared lookup by destination now finds none either; it also serves the encryption-in-progress branch of getAddressData(). Refs #445 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
TransactionTableModel took the address table model it reads labels from with parent->getAddressTableModel() in its initialiser list, which gives the complete model only because the WalletModel constructor creates the transaction table before anything can call refresh(). Reordering that constructor could have left the transaction list reading a model that lists only legacy addresses. The wallet model now passes the complete model explicitly. Also correct two comments: getAddressData() is no longer where the transaction list looks up its labels, and only a change made on another thread is queued while the wallet model's constructor runs. Refs #445 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
clang-tidy's performance-inefficient-vector-operation, which the tidy job treats as an error, flagged two loops in the new label tests that grow a vector one element at a time. Refs #445 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
WalletModel::updateAddressBook() queued a pass over the transaction history for every address book notification, including the many that change no label: the unlabelled receiving entry the wallet files for each address it finds used while it connects blocks or rescans, a change of purpose only, and the removal of an unlabelled entry. The transaction list shows nothing of an entry but its label, so compare the label the complete address table model gives for the address before and after the update, and queue the pass only if it changed. An entry no address decodes to, which no row can show, no longer pulls every row without an address into the pass. Also state which wallet paths notify with the wallet lock held: for a change made on the GUI thread, CWallet::DelAddressBook (inside a database transaction) and CWallet::GetNewDestination do, while CWallet::SetAddressBookWithDB notifies after releasing it. The test for the deferred pass now removes an entry, as DelAddressBook does. Refs #445 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 4bae798f19
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
The GUI keeps the address book in its address table models and updates them from the wallet's address book notifications. Those can arrive in another order than the writes they report, so the GUI needs to compare the entries a notification named with the wallet, without waiting for the wallet lock on its thread. interfaces::Wallet::tryGetAddresses() reads the entries for a list of destinations under one TRY_LOCK(cs_wallet), as tryGetBalances() and tryGetTxStatus() do, and gives up if the lock is busy. Each entry is what getAddresses() lists for that destination, with the same purpose fallback for old wallets, or none if the wallet has no entry other than a change one. The synthetic test wallet gains the counterpart, which counts its calls and gives up while its lock stand-in excludes the caller. Refs #445 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
CWallet::SetAddressBookWithDB() notifies after releasing cs_wallet, so when two writers change one entry the notifications can arrive in the opposite order to the writes. WalletModel::updateAddressBook() applied them in arrival order and kept the older label. Before the transaction list read labels from the address table model, its rows read the wallet on every repaint and recovered; now the rows, label searches and sorts kept the older label until another change to that address or a restart. Each notification is still applied to the address table models at once. The address it names is also recorded, and one queued step per event-loop pass reads the wallet's entries for every recorded address with tryGetAddresses(), which never waits for the wallet lock: while the lock is busy, as while a block is connected or the wallet is being encrypted, the addresses are kept and the step runs again after MODEL_UPDATE_DELAY. Where the complete address table model's row differs from the wallet's entry (missing, extra, another label or another type), the step applies the wallet's state through the same updateEntry() path a notification takes, to the complete model and the current one, and queues a label pass if the label shown changed. As every notification is followed by such a step, the models end at the wallet's state whatever order the notifications arrived in. Refs #445 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review of the address book reconcile found two cases it got wrong, neither of which today's wallet writers reach. An entry the wallet holds under a destination its encoding does not name, such as one that encodes to the empty string, or an address the chain does not decode, cannot be looked up by that encoding. The wallet read found no entry, and the reconcile removed the row. Such addresses are now skipped, and the row stays as its notifications left it. The reconcile reads every recorded entry and then applies the differences one by one. If a listener ran a nested event loop that delivered a newer notification for an address still to come, the older read was applied over it and nothing recorded the address again. A count of the notifications applied now shows that this happened, and the remaining addresses are read again in another reconcile, as the label pass does when its rows change under it. Also test the reconcile while the legacy-only model is current, for a legacy entry relabelled and for entries it adds and removes, and share the WalletAddress construction, with its purpose fallback for old wallets, between getAddresses() and tryGetAddresses(). Refs #445 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
@codex review |
|
Codex Review: Didn't find any major issues. Delightful! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
The transaction list resolved each row's label with
AddressTableModel::labelForAddress, which asks the wallet under a blockingcs_walletlock. That ran on every repaint of a visible row and on every filter or sort pass over the history, and it waited whenever the wallet held its lock, for example for each connected block. On a wallet with a long history this freezes the GUI while the node catches up.The transaction table now reads labels from the address table model's rows (
cachedLabelForAddress). It keeps the decode-then-encode normalisation of the wallet lookup and gives no label to an address that does not decode, as the wallet does. Its label source is the address table model the wallet model was created with, which lists every address, and the wallet model passes it explicitly. That holds after the Sign Message dialog has hadWalletModel::refresh()hand out a legacy-only model.WalletModelregisters for address-book changes before its address table model reads the address book, so changes made while the history loads are no longer lost, and it updates the complete model and the current one only.Because nothing reads the wallet on repaint any more, an address-book change invalidates the transaction rows that show that address. Notifications can arrive in another order than the writes they report (
CWallet::SetAddressBookWithDBnotifies after releasing the wallet lock), so each one is also followed by a comparison of the entries it named with the wallet. That comparison runs from the event loop and uses a new non-blocking read,interfaces::Wallet::tryGetAddresses(), a singleTRY_LOCK(cs_wallet)for every recorded address. Where the complete address table model's row differs from the wallet's entry, it applies the wallet's state the way a notification would. An address whose encoding does not decode to a destination the wallet can look up is left as its notifications left it, and if a listener delivers a newer notification while a correction is applied, the remaining entries are read again rather than overwritten with the older read. While the lock is busy, as while a block is connected or the wallet is being encrypted, it retries after 250 ms and never waits. However the notifications were ordered, the models end at the wallet's state. The address table models still take a change at once, inside the wallet's notification; for a change made on the GUI thread,CWallet::DelAddressBookandCWallet::GetNewDestinationraise it with the wallet lock held. The transaction table only records the address there, and only if its label changed: the unlabelled receiving entries the wallet files while it syncs or rescans, purpose-only changes and the removal of unlabelled entries cost nothing. It makes one pass over the history from the event loop, after the notification has returned. That one pass covers every address changed meanwhile, so a burst of changes costs one pass instead of one per change.The pass sends a single
dataChanged()for the address column, from the first affected row to the last. A single signal is needed for correctness:QSortFilterProxyModelsorts the rows of each signal against the rest, assuming the rest is in order, so per-range signals left a list sorted by label wrong. Filters still see every covered row, and a list sorted by date is not sorted again. If a listener adds or removes rows meanwhile, the pass is repeated instead of dropping rows.Dialog actions (coin control, send entries, the edit-address duplicate check) and
purposeForAddressstill read the wallet.Tests use the synthetic wallet and a real descriptor wallet. They cover:
getAddresscall and no wait while another thread holds the wallet lock;pk_hash_onlyrefresh;Each fails without its part of the change.
Measured on 100,000 synthetic rows with two proxies:
Known limits: a failed address-book database write sends no notification, so the list keeps the old label until the next change to that address or a restart. While the wallet lock is busy, a label from notifications that arrived out of order can show until the next retry finds the lock free (every 250 ms). The non-blocking read calls
IsMine, which can wait on the wallet's descriptor locks astryGetTxStatuscan. A row inserted between a label change made on the GUI thread and the following label pass can be placed wrongly in a list sorted on the address column if its own label did not change; the next sort corrects it. Each lookup still decodes and re-encodes the address.Proposed release note
Refs #445
🤖 Generated with Claude Code