test: prove out-of-order block processing causes stale UTXOs#650
Draft
test: prove out-of-order block processing causes stale UTXOs#650
Conversation
Adds test_out_of_order_block_processing_stale_utxo which demonstrates that when blocks are processed in non-ascending height order, spent UTXOs are never removed from the wallet. Scenario: Block H1 creates a UTXO for our address, block H2 spends it to an external address. In correct order (H1→H2) the balance returns to zero. In reverse order (H2→H1) the spending tx finds no UTXO to remove (sent=0), then the creating tx adds the UTXO permanently. The test currently FAILS — it asserts the expected correct behavior (balance=0 after both blocks) which is violated by the bug. Closes #649 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
test_out_of_order_block_processing_stale_utxotokey-wallet-managerproving that out-of-order block processing leaves spent UTXOs in the walletThe Bug
When compact block filters match multiple blocks and they are downloaded/processed in non-ascending height order, UTXO spends are silently missed:
sent=0Observed in production on Dash testnet: block 1458904 (spending) was processed 48ms before block 1458841 (creating). Trace logs confirmed
sent=0for the spending tx.Closes #649
Test plan
cargo test -p key-wallet-manager test_out_of_order_block_processing_stale_utxo— currently FAILS (proving the bug)🤖 Co-authored by Claudius the Magnificent AI Agent