Skip to content

test: Add wallet reorg test during assumeutxo background sync - #34535

Closed
b-l-u-e wants to merge 1 commit into
bitcoin:masterfrom
b-l-u-e:test-wallet-reorg-assumeutxo
Closed

b-l-u-e wants to merge 1 commit into
bitcoin:masterfrom
b-l-u-e:test-wallet-reorg-assumeutxo

Conversation

@b-l-u-e

@b-l-u-e b-l-u-e commented Feb 8, 2026

Copy link
Copy Markdown
Contributor

This PR adds a test that verifies wallet balance consistency when a chain reorg occurs while assumeutxo background validation is in progress

motivation
currently test file tests wallet functionality with snapshots but there is no test covering what happens when reorg occurs during background validation phase.

so what it tests

  • wallet state remains consistent through reorg
  • balance updates when coins are orphaned

@DrahtBot DrahtBot added the Tests label Feb 8, 2026
@DrahtBot

DrahtBot commented Feb 8, 2026 •

Copy link
Copy Markdown
Contributor

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

Code Coverage & Benchmarks

For details see: https://corecheck.dev/bitcoin/bitcoin/pulls/34535.

Reviews

See the guideline and AI policy for information on the review process.

Type Reviewers
Concept ACK yuvicc, aditrajj
Stale ACK Bortlesboat

If your review is incorrectly listed, please copy-paste <!--meta-tag:bot-skip--> into the comment that the bot should ignore.

@b-l-u-e
b-l-u-e marked this pull request as ready for review February 9, 2026 11:15

@yuvicc yuvicc left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Concept ACK

Comment thread test/functional/wallet_assumeutxo.py Resolved
@b-l-u-e
b-l-u-e force-pushed the test-wallet-reorg-assumeutxo branch 2 times, most recently from b403bde to 7536810 Compare February 16, 2026 20:15

@Bortlesboat Bortlesboat left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

ACK 75368100aa36ce136039b734c317354a04ef783b. Ran wallet_assumeutxo.py locally on Ubuntu 24.04, all tests pass including the new reorg-during-background-sync test.

Comment thread test/functional/wallet_assumeutxo.py Resolved
@DrahtBot
DrahtBot requested a review from yuvicc March 15, 2026 22:13
@aditrajj

Copy link
Copy Markdown

Concept ACK

Comment thread test/functional/wallet_assumeutxo.py Resolved
@sedited

sedited commented Apr 27, 2026

Copy link
Copy Markdown
Contributor

@b-l-u-e There are a bunch of unresolved review comments here. Can you respond to them?

@b-l-u-e

b-l-u-e commented Apr 27, 2026

Copy link
Copy Markdown
Contributor Author

@b-l-u-e There are a bunch of unresolved review comments here. Can you respond to them?

thanks for the reminder

@b-l-u-e
b-l-u-e force-pushed the test-wallet-reorg-assumeutxo branch from 7536810 to ad99afd Compare April 27, 2026 21:50
@b-l-u-e
b-l-u-e requested review from Bortlesboat and maflcko April 27, 2026 21:57

@Bortlesboat Bortlesboat left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

ACK ad99afd3da255703547e00f1fe8e4bd60a403c75. Re-reviewed the changes since my previous ACK 75368100aa36ce136039b734c317354a04ef783b, including the switch from removing the pruned node chain directory to the -reindex/-mocktime path and the shorter transaction confirmation timeout. Built current tip on WSL2 Ubuntu 24.04 with wallet support enabled and ran test/functional/wallet_assumeutxo.py; the test passed.

Comment thread test/functional/wallet_assumeutxo.py Resolved
@b-l-u-e
b-l-u-e force-pushed the test-wallet-reorg-assumeutxo branch from ad99afd to e42bff6 Compare April 28, 2026 09:18
@sedited
sedited requested a review from maflcko May 2, 2026 20:48
@Herb-ops

Copy link
Copy Markdown

Comment-only on e42bff6.

I don't think the new test currently guarantees that the reorg occurs while assumeutxo background validation is still in progress.

getchainstates()["chainstates"][-1] is the active, most-work snapshot chainstate. Waiting for its height to exceed SNAPSHOT_BASE_HEIGHT only shows that the snapshot chainstate has advanced past height 299; it does not show that the separate historical/background chainstate still exists.

In a fresh --nocleanup run, node3 logged:

  • snapshot fully validated: 09:50:52.889
  • wallet payment observed: 09:50:53.720
  • first reorg BlockDisconnected: 09:50:54.115

I also temporarily asserted len(n3.getchainstates()["chainstates"]) == 2 immediately before reconnecting node3 to deliver the competing chain. It failed because the result contained only one chainstate.

So this appears to test wallet balance handling across a reorg after background validation has completed, rather than during it. Could the test arrange for background validation to remain incomplete and assert that there are still two chainstates immediately before delivering the reorg?

@sedited

sedited commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

@b-l-u-e do you want to address the most recent review comment here?

@sedited

sedited commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

This hasn't received much reviewer attention and the author has not responded in a while. Given the amount of open work, ~400 open pull requests, I'm going to close this for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants