You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I hit this assertion in a test running on Antithesis.
Vibe coded functional test to demonstrate: dergoegge@587e42c. Because this is caused by a race condition, the commit also includes a sleep to reliably trigger the issue.
Assertion discount >= 0 fails in SelectionResult::SetBumpFeeDiscount (src/wallet/coinselection.cpp:823).
Found during Antithesis testing with concurrent transaction creation.
Root Cause
Race condition between two MiniMiner calculations during coin selection:
Individual bump fees calculated in AvailableCoins (spend.cpp:517) via calculateIndividualBumpFees() - creates MiniMiner, copies mempool state, releases lock
Combined bump fee calculated later in ChooseSelectionResult (spend.cpp:809) via calculateCombinedBumpFee() - creates a new MiniMiner with potentially different mempool state
Each MiniMiner constructor acquires LOCK(mempool.cs) only for the duration of the constructor (mini_miner.cpp:26). The lock is released before the actual fee calculations run.
If mempool state changes between these two calls (e.g., fee deltas modified via prioritisetransaction, new transactions, evictions), the combined calculation can return a higher value than the sum of individual calculations:
// spend.cpp:813-815
CAmount bump_fee_overestimate = summed_bump_fees - combined_bump_fee.value();
if (bump_fee_overestimate) {
result.SetBumpFeeDiscount(bump_fee_overestimate); // negative if combined > summed
}
Activity
vamshi567bh commentedon Jan 29, 2026
@fanquake Can I work on this
wallet: guard against negative bump fee discount from mempool race
Merge #35633: wallet: avoid call bumpfeediscount with negative values
Merge bitcoin/bitcoin#35633: wallet: avoid call bumpfeediscount with …
Merge bitcoin/bitcoin#35633: wallet: avoid call bumpfeediscount with …