Repository navigation
Conversation
|
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. External sites
ReviewsSee the guideline and AI policy for information on the review process.
If your review is incorrectly listed, please copy-paste ConflictsNo conflicts as of last run. |
|
I’ll take a closer look, but what’s the motivation for those changes? |
As mentioned in the last line of the PR description, it started from the review of PR #34857 here: #34857 (comment) |
|
Thanks for asking, made me realise that the motivation was obscured away at the end of the PR description. |
pablomartin4btc
left a comment
There was a problem hiding this comment.
Concept ACK
The goal is correct — the old "Reindex..." comment was misleading, the restart never used -reindex, and rescanblockchain is sufficient to test birthtime updates (the restart coverage was dropped intentionally). All the optimisations check out: 20 blocks × 10 min = 200 min > 2h window, COINBASE_MATURITY + 1 is the right minimum, and bumpmocktime is cleaner than the custom helper.
In PR description, at bullet point 3, "Generate 30 blocks fewer to accommodate for the wallet scan start time while importing descriptor with 'now' timestamp.", it's more accurate to say "30 fewer because 20 blocks is sufficient to surpass the 2-hour rescan window."
Commit structure:
The commit ordering creates a transient inconsistency: commit 1 renames the class to WalletBirthTimeTest but the file is still wallet_reindex.py, so at that commit the class and file names are mismatched. Cleaner would be to rename both the file and class together in commit 1 (pure rename, git detects with --find-renames), then overhaul the content in commit 2 — that way the class and file names always match across commits. Or a single commit since it's all test-only changes.
I think commit prefixes should both be test: — no production wallet code is touched.
Left an inline comment...
fbbbe75 to
4996874
Compare
pablomartin4btc
left a comment
There was a problem hiding this comment.
ACK 4996874
Thanks for taking the suggestions.
polespinasa
left a comment
There was a problem hiding this comment.
I am not sure about removing the restart.
Friendly pinging @furszy. Do you remember why you added it in the first place? Do you think it is correct to remove it or are we losing useful test coverage with it?
|
@rkrux can you follow up on @polespinasa's review? |
4996874 to
2459a74
Compare
1651ac0 Merge bitcoin#34857: test: Remove confusing assert_debug_log in wallet_reindex.py (merge-script) Pull request description: ## Issue being fixed or feature implemented `wallet_reindex.py --descriptors` failed all three attempts of `linux64-test / Test source` on a runner with very slow disk I/O ([job](https://github.com/dashpay/dash/actions/runs/44822540261/job/136598984598)): ``` File "test/functional/wallet_reindex.py", line 75, in birthtime_test with node.assert_debug_log(expected_msgs=["loadblk thread exit"]): AssertionError: [node 0] Expected messages "['loadblk thread exit']" does not partially match log ``` `assert_debug_log` starts its deadline (2 s × timeout factor, so 8 s in CI) when the `with` block is entered. The block then contains a full `restart_node`, so the stop, the restart and the whole reindex all run inside those 8 s. In the failing run the stop alone took about 30 s, loading the block index took about 4 s and reconnecting 160 blocks took about 17 s. Nothing was stuck. By the time `restart_node` returned, the deadline had long expired, so `assert_debug_log` read the log only once. `restart_node` returns as soon as `getmempoolinfo` reports `loaded`. In Dash that flag is set partway through the `loadblk` thread: after it the thread still sends tip notifications, writes the evodb repair marker with a forced chainstate flush, and fills the masternode coin cache before `loadblk thread exit` is logged. In the failing log the node was inside that final flush when the single read happened. So the test passes only when the entire stop/restart/reindex fits in the deadline or the remaining work happens to finish before the read. Bitcoin Core hit the same race with its `initload` thread and fixed it in bitcoin#34857 by removing the wait. `restart_node` already waits for the import to finish, and the wallet RPCs that follow call `BlockUntilSyncedToCurrentChain()`, so the extra `syncwithvalidationinterfacequeue()` can go too. ## What was done? Backport of bitcoin#34857 (test: Remove confusing assert_debug_log in wallet_reindex.py). Dash adaptations: - The removed wait names Dash's `loadblk` thread instead of `initload`. The surrounding context differs because Dash still runs this test with `--legacy-wallet`. - `-reindex=1` is kept on the restart. Upstream's change also drops it, which leaves the test restarting without reindexing even though it still logs "Reindex ...". Keeping it preserves what the test is named for. bitcoin#34879 (open upstream) proposes removing this restart entirely. ## How Has This Been Tested? Ran the test directly in a loop on a heavily loaded Linux x86_64 host (RelWithDebInfo build of this branch), 10 at a time, datadirs on disk: | | `--timeout-factor=1` | `--timeout-factor=4` | | --- | --- | --- | | develop | 14 of 40 failed with the CI assertion | 0 of 40 failed | | this PR | 0 of 80 failed | 0 of 40 failed | Both 40-run batches on this branch used upstream's exact pick (no `-reindex`); the 80 runs used the final version, which keeps it. A `--nocleanup` run confirms the restart reindexes (`Reindexing block file` in the node log). `test_runner.py` with 8 × `wallet_reindex.py --descriptors` and 8 × `wallet_reindex.py --legacy-wallet` passes. `test/lint/lint-python.py` reports no new findings (its only output is three mypy errors that develop shows too). `feature_reindex.py` (`kill_after_reindex`) uses the same `assert_debug_log` around `start_node`, but there waiting for the thread exit is the point, and its 10 s × timeout-factor budget covers only the start and reindex, not a stop. It has not been seen failing, so it is left unchanged. ## Breaking Changes None. Test-only. ## Checklist: - [x] I have performed a self-review of my own code - [ ] I have made corresponding changes to the documentation - [x] I have assigned this pull request to a milestone 🤖 Generated with [Claude Code](https://claude.com/claude-code) Top commit has no ACKs. Tree-SHA512: 7e89f9fbc450899e5d1d8e6d4c51999af91b7880a663c2fa23d9bb76d59b85270b8815bbc55409fea6d8e7c207b33d4775a133329e0b6229fe202eff085ecf6d
This rename precedes the change in intention of the test in the subsequent commit.
Changes done: - The node doesn't need to be restarted (with reindex or without) because rescanblockchain RPC already updates the wallet birthtime, which is the property that needs to be tested - this allows us to rename the test class to highlight the change in intention of the test. - Generate 9 blocks fewer to fund the miner wallet. - Generate 30 blocks fewer because 20 are sufficient to surpass the wallet rescan window. - Use common bumpmocktime helper instead of custom advance_time function. - Unload miner wallet before 20 blocks generation to avoid notifications from being processed by that wallet. - Change the order of arguments in assert_equal for consistency. - Add few constants and verbose comments for test clarity while removing comments that allude to legacy wallets.
2459a74 to
af88705
Compare
|
Addressed comments and rebased. |
pablomartin4btc
left a comment
There was a problem hiding this comment.
re-ACK af88705
Since my last review: rebase, comment rewording from @polespinasa's review, and the wallet reload check, which restores the coverage of the birth time being reconstructed in CWallet::LoadToWallet from the saved tx (good catch @polespinasa, I missed that).
Correcting my earlier review, where I said the restart never used -reindex and that its coverage was dropped intentionally: the test was added in #28920 as the regression test for #28897 (tx going to 0 confirmations after -reindex when it's older than the birth time), and #34857 dropped -reindex=1 from the restart without mentioning it.
Non-blocking: I tested reverting the #28920 fix (removing both MaybeUpdateBirthTime(wtx.GetTxTime()) calls in AddToWallet and LoadToWallet): the birth time assert here still catches it, but the reindex symptom itself is no longer covered. With 50 blocks and a -reindex restart instead of the reload, the tx drops to 0 confirmations; with 20 blocks it stays confirmed, since blocks are only skipped when chain_time_max < m_birth_time - TIMESTAMP_WINDOW * 2, so covering it would need >~30 blocks. Fine to leave as is or for a follow-up, cc @furszy.
Test results and trace (fix reverted)
| blocks | reload (this PR) | -reindex restart |
|---|---|---|
| 20 | fails: birth time assert (20 confs) | fails: birth time assert (20 confs) |
| 50 | fails: birth time assert (50 confs) | fails: confirmations 0 != 50 |
With the fix in place all four pass. -reindex variant: replaced the unload/loadwallet with self.restart_node(0, extra_args=['-reindex', f'-mocktime={node.mocktime}', '-wallet=watch_only']).
Why the tx drops to 0 confirmations (traced with extra logging): on -reindex the wallet loads before the block index is rebuilt, so CWalletTx::updateState marks the tx Inactive; when its block is reconnected, blockConnected skips it (chain_time_max < m_birth_time - TIMESTAMP_WINDOW * 2), so the tx is never re-confirmed. With a plain reload the block is already in the chain, so the tx stays confirmed regardless of the birth time.
nit: the first bullet of the commit message (and PR description) still says the restart isn't needed since rescanblockchain already updates the birthtime. That's no longer the whole story: a reload was added because rescanblockchain doesn't cover the birth time being reconstructed from the saved tx on wallet load (CWallet::LoadToWallet).
polespinasa
left a comment
There was a problem hiding this comment.
ACK af88705
Thanks for addressing feedback

The need for this change was ideated during the review of #34857.
rescanblockchain RPC already updates the wallet birthtime, which is the property
that needs to be tested - this allows us to rename the test class to highlight
the change in intention of the test.
rescan window.
being processed by that wallet.
Note: This overhaul helps in reducing the time taken by the test from 2s to 0s as observed in few runs.