Skip to content

test: verify node state after restart in assumeutxo - #34286

Merged
achow101 merged 1 commit into
bitcoin:masterfrom
yashbhutwala:test-wallet-assumeutxo-restart-state
Feb 24, 2026
Merged

achow101 merged 1 commit into
bitcoin:masterfrom
yashbhutwala:test-wallet-assumeutxo-restart-state

Conversation

@yashbhutwala

Copy link
Copy Markdown
Contributor

Summary

This PR replaces the TODO comment in wallet_assumeutxo.py (line 242) with actual test assertions that verify node and wallet behavior after a restart during assumeutxo background sync.

Changes

The new tests verify:

  • Two chainstates exist (background validation not complete)
  • Background chainstate is still at START_HEIGHT
  • Snapshot chainstate has synced to at least PAUSE_HEIGHT
  • Wallets cannot be loaded after restart (expected behavior)
  • Wallet backup from before snapshot height cannot be restored

Motivation

During implementation, I discovered that wallets cannot be loaded after a node restart during assumeutxo background sync. This is expected behavior because:

  • The wallet loading code checks if required blocks are available for rescanning
  • During assumeutxo background sync, blocks before the snapshot are not available
  • This applies to all wallets, including watch-only wallets created at the snapshot height

This is a valuable test addition because it documents this expected behavior and ensures it doesn't regress. Users should be aware that if they restart their node during assumeutxo background sync, they won't be able to load their wallets until the background sync completes.

Related

refs #28648

Addresses the TODO comment that was originally added as part of the assumeutxo wallet test implementation.

@DrahtBot DrahtBot added the Tests label Jan 14, 2026
@DrahtBot

DrahtBot commented Jan 14, 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/34286.

Reviews

See the guideline for information on the review process.

Type Reviewers
ACK fjahr, sedited, polespinasa, Bicaru20, achow101

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.

@Bicaru20

Copy link
Copy Markdown
Contributor

I tested the changes, and the test wallet_assumeutxo.py passes.
The newly added assertions look good — they correctly verify the node state (number of chainstates and their respective heights). The test also checks that wallets cannot be loaded after a node restart, and finally confirms that restoring a wallet with a backup that predates the snapshot height is not allowed.
Overall, the code looks solid. I’ve left a few minor comments and questions for clarification.

@yashbhutwala

Copy link
Copy Markdown
Contributor Author

I’ve left a few minor comments and questions for clarification.

@Bicaru20 I don't see any comments or questions.

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

Copy link
Copy Markdown
Contributor

I’ve left a few minor comments and questions for clarification.

@Bicaru20 I don't see any comments or questions.

My bad, now you should be able to see them

@yashbhutwala
yashbhutwala force-pushed the test-wallet-assumeutxo-restart-state branch from fc1b15c to 30d05c7 Compare January 14, 2026 19:35
@yashbhutwala
yashbhutwala requested a review from Bicaru20 January 14, 2026 19:37
@fjahr

fjahr commented Jan 15, 2026

Copy link
Copy Markdown
Contributor

Concept ACK

@Bicaru20

Copy link
Copy Markdown
Contributor

Looks like some CI tests are failing. Probably because of the assert I suggested to change (my bad, sorry). You probably should test if the assert is the problem and change it back to what you had.

@yashbhutwala
yashbhutwala force-pushed the test-wallet-assumeutxo-restart-state branch from 30d05c7 to 3680ccb Compare January 15, 2026 15:21
@yashbhutwala

yashbhutwala commented Jan 15, 2026 •

Copy link
Copy Markdown
Contributor Author

@Bicaru20 Thanks for catching this! You were right that the CI failed.

The failure showed AssertionError: not(360 == 359) - the snapshot chainstate was at height 360, not 359.

This confirms what the stopatheight documentation says: "Blocks after target height may be processed during shutdown."

I've reverted back to assert_greater_than_or_equal with a clearer comment explaining why:

# The snapshot chainstate should be at least PAUSE_HEIGHT. It may be
# higher because stopatheight may allow additional blocks to be
# processed during shutdown (per stopatheight documentation).
assert_greater_than_or_equal(chainstates[1]['blocks'], PAUSE_HEIGHT)

I kept the [1] index suggestion since that's still clearer when we've verified len(chainstates) == 2.

@Bicaru20

Bicaru20 commented Jan 17, 2026 •

Copy link
Copy Markdown
Contributor

Test code ACK. Everything looks good!

@yashbhutwala

Copy link
Copy Markdown
Contributor Author

Is this good to merge?

@fjahr fjahr 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.

Is this good to merge?

No, there are only concept ACKs here so far, so it needs more review.

Comment thread test/functional/wallet_assumeutxo.py Resolved
@yashbhutwala
yashbhutwala force-pushed the test-wallet-assumeutxo-restart-state branch 2 times, most recently from 19e76b4 to 2ecf4f0 Compare January 22, 2026 14:23
@yashbhutwala
yashbhutwala requested a review from fjahr January 22, 2026 14:35

@fjahr fjahr 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.

utACK 2ecf4f0183a87c32540d4c18c36346bd8794d522

Would be nice to address my comments but also fine if you wait for more review comments. It would be also fine for me if this is merged as is.

Comment thread test/functional/wallet_assumeutxo.py Resolved
Comment thread test/functional/wallet_assumeutxo.py Resolved
@yashbhutwala
yashbhutwala force-pushed the test-wallet-assumeutxo-restart-state branch from 2ecf4f0 to 29cd279 Compare January 23, 2026 14:30
Replace the TODO comment in wallet_assumeutxo.py with actual test
assertions that verify node and wallet behavior after a restart
during assumeutxo background sync.

The new tests verify:
- Two chainstates exist (background validation not complete)
- Background chainstate is still at START_HEIGHT
- Snapshot chainstate has synced to at least PAUSE_HEIGHT
- Wallets cannot be loaded after restart (expected behavior during
  background sync because blocks before snapshot are unavailable
  for rescanning)
- Wallet backup from before snapshot height cannot be restored

This documents the expected behavior that wallets cannot be loaded
after a node restart during assumeutxo background sync, which is
an important edge case for users to be aware of.

refs bitcoin#28648
@yashbhutwala
yashbhutwala force-pushed the test-wallet-assumeutxo-restart-state branch from 29cd279 to 5cd5794 Compare January 23, 2026 14:32
@yashbhutwala
yashbhutwala requested a review from fjahr January 23, 2026 14:34

@fjahr fjahr 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 5cd5794

Thanks for implementing my suggestions.

PastaPastaPasta added a commit to PastaPastaPasta/dash that referenced this pull request Nov 11, 2026
…o.py

faa68ed test: Fix intermittent issue in wallet_assumeutxo.py

Pull request description:

  -stopatheight may let a few more blocks through during shutdown. Sync the
  node to the pause height with submitblock instead of restarting it, and
  unload the wallets so the loading checks still apply.

Dash adaptations:
- setup_network() keeps its form; the pruned-node rows are absent, as for
  bitcoin#34286.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
PastaPastaPasta added a commit to PastaPastaPasta/dash that referenced this pull request Nov 11, 2026
5cd5794 test: verify node state after restart in assumeutxo

Pull request description:

  Replace the TODO after the restart during background sync with checks of
  the chainstates and of wallet loading, which still needs the blocks below
  the snapshot.

Dash adaptations:
- The pruned-node rows that use the same error helper are absent: a node
  does not load snapshots with -prune in this tree.
- A blank line precedes the nested helper, for this tree's flake8 (E306).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
PastaPastaPasta added a commit to PastaPastaPasta/dash that referenced this pull request Nov 11, 2026
…o.py

faa68ed test: Fix intermittent issue in wallet_assumeutxo.py

Pull request description:

  -stopatheight may let a few more blocks through during shutdown. Sync the
  node to the pause height with submitblock instead of restarting it, and
  unload the wallets so the loading checks still apply.

Dash adaptations:
- setup_network() keeps its form; the pruned-node rows are absent, as for
  bitcoin#34286.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
PastaPastaPasta added a commit to PastaPastaPasta/dash that referenced this pull request Nov 11, 2026
5cd5794 test: verify node state after restart in assumeutxo

Pull request description:

  Replace the TODO after the restart during background sync with checks of
  the chainstates and of wallet loading, which still needs the blocks below
  the snapshot.

Dash adaptations:
- The pruned-node rows that use the same error helper are absent: a node
  does not load snapshots with -prune in this tree.
- A blank line precedes the nested helper, for this tree's flake8 (E306).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
PastaPastaPasta added a commit to PastaPastaPasta/dash that referenced this pull request Nov 11, 2026
…o.py

faa68ed test: Fix intermittent issue in wallet_assumeutxo.py

Pull request description:

  -stopatheight may let a few more blocks through during shutdown. Sync the
  node to the pause height with submitblock instead of restarting it, and
  unload the wallets so the loading checks still apply.

Dash adaptations:
- setup_network() keeps its form; the pruned-node rows are absent, as for
  bitcoin#34286.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
PastaPastaPasta added a commit to PastaPastaPasta/dash that referenced this pull request Nov 12, 2026
5cd5794 test: verify node state after restart in assumeutxo

Pull request description:

  Replace the TODO after the restart during background sync with checks of
  the chainstates and of wallet loading, which still needs the blocks below
  the snapshot.

Dash adaptations:
- The pruned-node rows that use the same error helper are absent: a node
  does not load snapshots with -prune in this tree.
- A blank line precedes the nested helper, for this tree's flake8 (E306).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
PastaPastaPasta added a commit to PastaPastaPasta/dash that referenced this pull request Nov 12, 2026
…o.py

faa68ed test: Fix intermittent issue in wallet_assumeutxo.py

Pull request description:

  -stopatheight may let a few more blocks through during shutdown. Sync the
  node to the pause height with submitblock instead of restarting it, and
  unload the wallets so the loading checks still apply.

Dash adaptations:
- setup_network() keeps its form; the pruned-node rows are absent, as for
  bitcoin#34286.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
PastaPastaPasta added a commit to PastaPastaPasta/dash that referenced this pull request Nov 13, 2026
5cd5794 test: verify node state after restart in assumeutxo

Pull request description:

  Replace the TODO after the restart during background sync with checks of
  the chainstates and of wallet loading, which still needs the blocks below
  the snapshot.

Dash adaptations:
- The pruned-node rows that use the same error helper are absent: a node
  does not load snapshots with -prune in this tree.
- A blank line precedes the nested helper, for this tree's flake8 (E306).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
PastaPastaPasta added a commit to PastaPastaPasta/dash that referenced this pull request Nov 13, 2026
…o.py

faa68ed test: Fix intermittent issue in wallet_assumeutxo.py

Pull request description:

  -stopatheight may let a few more blocks through during shutdown. Sync the
  node to the pause height with submitblock instead of restarting it, and
  unload the wallets so the loading checks still apply.

Dash adaptations:
- setup_network() keeps its form; the pruned-node rows are absent, as for
  bitcoin#34286.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
PastaPastaPasta added a commit to PastaPastaPasta/dash that referenced this pull request Nov 14, 2026
5cd5794 test: verify node state after restart in assumeutxo

Pull request description:

  Replace the TODO after the restart during background sync with checks of
  the chainstates and of wallet loading, which still needs the blocks below
  the snapshot.

Dash adaptations:
- The pruned-node rows that use the same error helper are absent: a node
  does not load snapshots with -prune in this tree.
- A blank line precedes the nested helper, for this tree's flake8 (E306).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
PastaPastaPasta added a commit to PastaPastaPasta/dash that referenced this pull request Nov 14, 2026
…o.py

faa68ed test: Fix intermittent issue in wallet_assumeutxo.py

Pull request description:

  -stopatheight may let a few more blocks through during shutdown. Sync the
  node to the pause height with submitblock instead of restarting it, and
  unload the wallets so the loading checks still apply.

Dash adaptations:
- setup_network() keeps its form; the pruned-node rows are absent, as for
  bitcoin#34286.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
PastaPastaPasta added a commit to PastaPastaPasta/dash that referenced this pull request Nov 14, 2026
5cd5794 test: verify node state after restart in assumeutxo

Pull request description:

  Replace the TODO after the restart during background sync with checks of
  the chainstates and of wallet loading, which still needs the blocks below
  the snapshot.

Dash adaptations:
- The pruned-node rows that use the same error helper are absent: a node
  does not load snapshots with -prune in this tree.
- A blank line precedes the nested helper, for this tree's flake8 (E306).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
PastaPastaPasta added a commit to PastaPastaPasta/dash that referenced this pull request Nov 14, 2026
…o.py

faa68ed test: Fix intermittent issue in wallet_assumeutxo.py

Pull request description:

  -stopatheight may let a few more blocks through during shutdown. Sync the
  node to the pause height with submitblock instead of restarting it, and
  unload the wallets so the loading checks still apply.

Dash adaptations:
- setup_network() keeps its form; the pruned-node rows are absent, as for
  bitcoin#34286.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
PastaPastaPasta added a commit to PastaPastaPasta/dash that referenced this pull request Nov 19, 2026
5cd5794 test: verify node state after restart in assumeutxo

Pull request description:

  Replace the TODO after the restart during background sync with checks of
  the chainstates and of wallet loading, which still needs the blocks below
  the snapshot.

Dash adaptations:
- The pruned-node rows that use the same error helper are absent: a node
  does not load snapshots with -prune in this tree.
- A blank line precedes the nested helper, for this tree's flake8 (E306).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
PastaPastaPasta added a commit to PastaPastaPasta/dash that referenced this pull request Nov 19, 2026
…o.py

faa68ed test: Fix intermittent issue in wallet_assumeutxo.py

Pull request description:

  -stopatheight may let a few more blocks through during shutdown. Sync the
  node to the pause height with submitblock instead of restarting it, and
  unload the wallets so the loading checks still apply.

Dash adaptations:
- setup_network() keeps its form; the pruned-node rows are absent, as for
  bitcoin#34286.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
PastaPastaPasta added a commit to PastaPastaPasta/dash that referenced this pull request Nov 19, 2026
5cd5794 test: verify node state after restart in assumeutxo

Pull request description:

  Replace the TODO after the restart during background sync with checks of
  the chainstates and of wallet loading, which still needs the blocks below
  the snapshot.

Dash adaptations:
- The pruned-node rows that use the same error helper are absent: a node
  does not load snapshots with -prune in this tree.
- A blank line precedes the nested helper, for this tree's flake8 (E306).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
PastaPastaPasta added a commit to PastaPastaPasta/dash that referenced this pull request Nov 19, 2026
…o.py

faa68ed test: Fix intermittent issue in wallet_assumeutxo.py

Pull request description:

  -stopatheight may let a few more blocks through during shutdown. Sync the
  node to the pause height with submitblock instead of restarting it, and
  unload the wallets so the loading checks still apply.

Dash adaptations:
- setup_network() keeps its form; the pruned-node rows are absent, as for
  bitcoin#34286.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
PastaPastaPasta added a commit to PastaPastaPasta/dash that referenced this pull request Nov 19, 2026
5cd5794 test: verify node state after restart in assumeutxo

Pull request description:

  Replace the TODO after the restart during background sync with checks of
  the chainstates and of wallet loading, which still needs the blocks below
  the snapshot.

Dash adaptations:
- The pruned-node rows that use the same error helper are absent: a node
  does not load snapshots with -prune in this tree.
- A blank line precedes the nested helper, for this tree's flake8 (E306).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
PastaPastaPasta added a commit to PastaPastaPasta/dash that referenced this pull request Nov 19, 2026
…o.py

faa68ed test: Fix intermittent issue in wallet_assumeutxo.py

Pull request description:

  -stopatheight may let a few more blocks through during shutdown. Sync the
  node to the pause height with submitblock instead of restarting it, and
  unload the wallets so the loading checks still apply.

Dash adaptations:
- setup_network() keeps its form; the pruned-node rows are absent, as for
  bitcoin#34286.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
PastaPastaPasta added a commit to PastaPastaPasta/dash that referenced this pull request Nov 19, 2026
5cd5794 test: verify node state after restart in assumeutxo

Pull request description:

  Replace the TODO after the restart during background sync with checks of
  the chainstates and of wallet loading, which still needs the blocks below
  the snapshot.

Dash adaptations:
- The pruned-node rows that use the same error helper are absent: a node
  does not load snapshots with -prune in this tree.
- A blank line precedes the nested helper, for this tree's flake8 (E306).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
PastaPastaPasta added a commit to PastaPastaPasta/dash that referenced this pull request Nov 19, 2026
…o.py

faa68ed test: Fix intermittent issue in wallet_assumeutxo.py

Pull request description:

  -stopatheight may let a few more blocks through during shutdown. Sync the
  node to the pause height with submitblock instead of restarting it, and
  unload the wallets so the loading checks still apply.

Dash adaptations:
- setup_network() keeps its form; the pruned-node rows are absent, as for
  bitcoin#34286.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
PastaPastaPasta added a commit to PastaPastaPasta/dash that referenced this pull request Nov 19, 2026
5cd5794 test: verify node state after restart in assumeutxo

Pull request description:

  Replace the TODO after the restart during background sync with checks of
  the chainstates and of wallet loading, which still needs the blocks below
  the snapshot.

Dash adaptations:
- The pruned-node rows that use the same error helper are absent: a node
  does not load snapshots with -prune in this tree.
- A blank line precedes the nested helper, for this tree's flake8 (E306).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
PastaPastaPasta added a commit to PastaPastaPasta/dash that referenced this pull request Nov 19, 2026
…o.py

faa68ed test: Fix intermittent issue in wallet_assumeutxo.py

Pull request description:

  -stopatheight may let a few more blocks through during shutdown. Sync the
  node to the pause height with submitblock instead of restarting it, and
  unload the wallets so the loading checks still apply.

Dash adaptations:
- setup_network() keeps its form; the pruned-node rows are absent, as for
  bitcoin#34286.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
PastaPastaPasta added a commit to PastaPastaPasta/dash that referenced this pull request Nov 20, 2026
5cd5794 test: verify node state after restart in assumeutxo

Pull request description:

  Replace the TODO after the restart during background sync with checks of
  the chainstates and of wallet loading, which still needs the blocks below
  the snapshot.

Dash adaptations:
- The pruned-node rows that use the same error helper are absent: a node
  does not load snapshots with -prune in this tree.
- A blank line precedes the nested helper, for this tree's flake8 (E306).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
PastaPastaPasta added a commit to PastaPastaPasta/dash that referenced this pull request Nov 20, 2026
…o.py

faa68ed test: Fix intermittent issue in wallet_assumeutxo.py

Pull request description:

  -stopatheight may let a few more blocks through during shutdown. Sync the
  node to the pause height with submitblock instead of restarting it, and
  unload the wallets so the loading checks still apply.

Dash adaptations:
- setup_network() keeps its form; the pruned-node rows are absent, as for
  bitcoin#34286.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
PastaPastaPasta added a commit to PastaPastaPasta/dash that referenced this pull request Nov 20, 2026
5cd5794 test: verify node state after restart in assumeutxo

Pull request description:

  Replace the TODO after the restart during background sync with checks of
  the chainstates and of wallet loading, which still needs the blocks below
  the snapshot.

Dash adaptations:
- The pruned-node rows that use the same error helper are absent: a node
  does not load snapshots with -prune in this tree.
- A blank line precedes the nested helper, for this tree's flake8 (E306).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
PastaPastaPasta added a commit to PastaPastaPasta/dash that referenced this pull request Nov 20, 2026
…o.py

faa68ed test: Fix intermittent issue in wallet_assumeutxo.py

Pull request description:

  -stopatheight may let a few more blocks through during shutdown. Sync the
  node to the pause height with submitblock instead of restarting it, and
  unload the wallets so the loading checks still apply.

Dash adaptations:
- setup_network() keeps its form; the pruned-node rows are absent, as for
  bitcoin#34286.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
PastaPastaPasta added a commit to PastaPastaPasta/dash that referenced this pull request Nov 20, 2026
5cd5794 test: verify node state after restart in assumeutxo

Pull request description:

  Replace the TODO after the restart during background sync with checks of
  the chainstates and of wallet loading, which still needs the blocks below
  the snapshot.

Dash adaptations:
- The pruned-node rows that use the same error helper are absent: a node
  does not load snapshots with -prune in this tree.
- A blank line precedes the nested helper, for this tree's flake8 (E306).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
PastaPastaPasta added a commit to PastaPastaPasta/dash that referenced this pull request Nov 20, 2026
…o.py

faa68ed test: Fix intermittent issue in wallet_assumeutxo.py

Pull request description:

  -stopatheight may let a few more blocks through during shutdown. Sync the
  node to the pause height with submitblock instead of restarting it, and
  unload the wallets so the loading checks still apply.

Dash adaptations:
- setup_network() keeps its form; the pruned-node rows are absent, as for
  bitcoin#34286.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
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.

7 participants