mirror of
https://github.com/bitcoin/bitcoin
synced 2026-12-04 10:29:40 +00:00
wallet, test: remove unnecessary node restart from wallet_reindex #34879
No reviewers
Labels
No labels
Android
Backport
Block storage
Brainstorming
Bug
Build system
CI failed
Consensus
Data corruption
Descriptors
Docs
DrahtBot Guix build requested
Feature
Fuzzing
GUI
Good First Review
IPC
Insufficient Review
Kernel
Linux/Unix
Mempool
Mining
Needs Backport (31.x)
Needs Backport (32.x)
Needs Benchmark
Needs Conceptual Review
Needs backport (30.x)
Needs rebase
Needs release note
Net
P2P
PSBT
Privacy
Private Broadcast
Questions and Help
RPC/REST/ZMQ
Refactoring
Resource usage
Review club
Scripts and tools
Settings
TX fees and policy
Tests
Tracking Issue
UTXO Db and Indexes
Up for grabs
Upstream
Utils/log/libs
Validation
Waiting for author
Wallet
Windows
good first issue
interfaces
macOS
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
bitcoin/bitcoin!34879
Loading…
Reference in a new issue
No description provided.
Delete branch "wallet-birthtime"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
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.
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.
External sites
Reviews
See the guideline and AI policy for information on the review process.
If your review is incorrectly listed, please copy-paste
<!--meta-tag:bot-skip-->into the comment that the bot should ignore.Conflicts
No conflicts as of last run.
It appears that this overhaul helps in reducing the tests time as well from 2s to 0s, which is nice to see.
Few runs that I checked:
wallet_reindex test time in macOS native job in other PR1 and PR2 - 2 sec.
wallet_birthtime test time in macOS native job in this PR - 0 sec.
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: https://github.com/bitcoin/bitcoin/pull/34857#discussion_r2964881776
Thanks for asking, made me realise that the motivation was obscured away at the end of the PR description.
I updated the PR description to highlight the motivation at the start.
Concept ACK
The goal is correct — the old "Reindex..." comment was misleading, the restart never used
-reindex, andrescanblockchainis 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, andbumpmocktimeis 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
WalletBirthTimeTestbut the file is stillwallet_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...
nit: the comment says "Blank wallets" but the wallet isn't created with
blank=True— the comment should describe the actual condition instead.Taken along with other suggestions in the overall review comment.
ACK
4996874b58Thanks for taking the suggestions.
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?
in
4996874b58test: remove unnecessary restart from the test among other optimisationsBy removing this restart we are loosing some test coverage, we now don't that tx confirmations and the birthtime are preserved over restart under reindex.
in
3c260e70a1test: rename wallet_reindex to wallet_birthtimein
4996874test: remove unnecessary restart from the test among other optimisationsI find this comment really hard to read. The test is not mining 20blocks every 10min, it is mining 20 blocks, one every 10min.
in
4996874b58test: remove unnecessary restart from the test among other optimisationsI would rather keep
Blank. Although the wallet is not created using theblankparameter, ablankwallet is just a wallet without keys. A wallet that has private keys disabled and did not import yet a public descriptor is in fact a blank wallet.Sorry I just saw this after I added my comment: https://github.com/bitcoin/bitcoin/pull/34879#discussion_r3966210090
The wallet is in-fact a blank wallet, not
blank=Truedoes not mean that is notblank.As the wallet does not have private keys enabled, the wallet is at creation moment a blank wallet. The
blankparameter is useful for a wallet with private keys to not create new keys on creation and allow the user to import their own keys.I would rather revert this change.
I'm fine with that.
@rkrux can you follow up on @polespinasa's review?
🔵 Suggestion · The restart-to-reload coverage change is obscured by cleanup edits
In
af88705a, mixing the restart-to-wallet-reload change with setup optimizations and reordered assertions makes it harder to verify which reopening checks survive, and the commit message omits the replacement reload check.Location: test/functional/wallet_birthtime.py:81 (commit).
Review coverage was incomplete.
Reviewed:
af88705a9c83· Review report · Previous reportspermalink
True, this comment could have come across as confusing. Updated.
Either is fine, used both.
The original seems fine. There are instances of BirthTime in the codebase:
git grep 'BirthTime' -- '*.cpp' '*.h.I don't believe any test coverage is being lost here. The intent as per the original comments in this test file show that the correct update of wallet birthtime property needs to be tested, which can be achieved and tested via the rescanblockchain RPC. Once the transaction is seen while rescanning the blockchain, it's saved in the database and upon any further reload of wallet (with or without node restart), the birthtime is updated correspondingly. The test need not restart the node only to test the same assertion again.
Sorry for the late response, somehow I missed the mail notification from this comment.
It does indeed lose coverage. Try removing the call to
MaybeUpdateBirthTimeinCWallet:LoadToWallet. The new version of the test pass while before this commit it fails.You are right saying that restarting is unneeded, adding just a wallet reload check restores the coverage.
Added the wallet reload, thanks.
Addressed comments and rebased.
re-ACK
af88705a9cSince 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::LoadToWalletfrom the saved tx (good catch @polespinasa, I missed that).Correcting my earlier review, where I said the restart never used
-reindexand that its coverage was dropped intentionally: the test was added in #28920 as the regression test for #28897 (tx going to 0 confirmations after-reindexwhen it's older than the birth time), and #34857 dropped-reindex=1from the restart without mentioning it.Non-blocking: I tested reverting the #28920 fix (removing both
MaybeUpdateBirthTime(wtx.GetTxTime())calls inAddToWalletandLoadToWallet): the birth time assert here still catches it, but the reindex symptom itself is no longer covered. With 50 blocks and a-reindexrestart instead of the reload, the tx drops to 0 confirmations; with 20 blocks it stays confirmed, since blocks are only skipped whenchain_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)
-reindexrestartconfirmations0 != 50With the fix in place all four pass.
-reindexvariant: replaced the unload/loadwalletwithself.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
-reindexthe wallet loads before the block index is rebuilt, soCWalletTx::updateStatemarks the tx Inactive; when its block is reconnected,blockConnectedskips 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
rescanblockchainalready updates the birthtime. That's no longer the whole story: a reload was added becauserescanblockchaindoesn't cover the birth time being reconstructed from the saved tx on wallet load (CWallet::LoadToWallet).ACK
af88705a9cThanks for addressing feedback