What changed, and why it matters
This patch fixes a bookkeeping bug in Monero's transaction memory pool. When a new transaction was added, the code sometimes failed to mark it as a 'double spend' even when another part of the system had already detected a conflict. The fix makes the pool record the double-spend warning from the validation step, not just from a later secondary check. A missing flag could let conflicting transactions sit in the pool longer than they should, potentially affecting which transactions miners see or how nodes relay them.
Apply the patch. After applying, verify that transactions flagged as double spends during validation are correctly marked in the pool and are not relayed or included in block templates. Consider adding regression tests that inject a tvc.m_double_spend=true transaction and assert meta.double_spend_seen is set.
Security signals we found
Missing/incorrect state flag for double-spend detection
Reliance on a single secondary check while ignoring primary validation signal
Transaction pool metadata inconsistency
Potential for conflicting transactions to be relayed or mined due to stale flag
Evidence from the diff
In tx_pool.cpp, take_tx_from_txpool() sets meta.double_spend_seen. Previously it only consulted have_tx_keyimges_as_spent(tx, id). The patch adds tvc.m_double_spend as an additional source, OR-ing it with the key-image check. tvc (tx verification context) is populated earlier during transaction validation and can flag a double spend before the transaction is stored. The old code therefore dropped that signal if the local key-image check did not independently detect the same conflict, leaving the metadata inconsistent with the validation outcome.
Changed components
src/cryptonote_core/tx_pool.cppTransaction memory pool metadata (txpool_meta_t::double_spend_seen)Transaction validation context (tvc.m_double_spend)Inspect captured patch +1 / −1
### src/cryptonote_core/tx_pool.cpp
@@ -266,7 +266,7 @@ namespace cryptonote
meta.last_relayed_time = time(NULL);
meta.relayed = relayed;
meta.set_relay_method(tx_relay);
- meta.double_spend_seen = have_tx_keyimges_as_spent(tx, id);
+ meta.double_spend_seen = tvc.m_double_spend || have_tx_keyimges_as_spent(tx, id);
meta.pruned = tx.pruned;
meta.bf_padding = 0;
memset(meta.padding, 0, sizeof(meta.padding));Why this scored 58/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.