Test/longest chain double spend v2#386
Open
sugh01 wants to merge 9 commits intobsv-blockchain:mainfrom
Open
Conversation
…ing reorg During blockchain reorganizations in SubtreeProcessor.reorgBlocks(), conflicting transactions that lost to newly-mined transactions were being removed from block assembly but never marked as NOT on longest chain in the UTXO store, leaving them with UnminedSince = 0. Changes: - Modified moveForwardBlock() to return losingTxHashesMap alongside transactionMap - Updated reorgBlocks() with two-pass processing: * Pass 1: Collect winning and losing transactions from all moveForward blocks * Pass 2: Filter and mark transactions appropriately, removing losers from winners - Fixed test scenario in testLongestChainWithDoubleSpendTransaction to ensure parentTx2 is mined in both forks, making tx3 valid on both chains - Removed impossible test scenario where tx3 would be mined after tx2 already consumed the same UTXO This ensures proper UTXO state tracking during chain reorganizations and fixes failures in the longest_chain test suite, particularly on Aerospike backend. Co-Authored-By: Claude Sonnet 4.5 (1M context) <[email protected]>
fix: Mark losing conflicting transactions as NOT on longest chain during reorg
Contributor
|
🤖 Claude Code Review Status: Complete Review Summary: This PR implements fixes for tracking losing conflicting transactions during blockchain reorgs and adds comprehensive test coverage. Issues Found: None Key Changes:
The approach is sound - the two-pass processing ensures transactions that win in ANY moveForward block are properly excluded from the losing list. |
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.
No description provided.