Skip to content

fix(mempool): reconcile conflicts before insertion - #254

Draft
EddieHouston wants to merge 1 commit into
Blockstream:new-indexfrom
EddieHouston:fix/mempool-conflict-reconciliation
Draft

fix(mempool): reconcile conflicts before insertion#254
EddieHouston wants to merge 1 commit into
Blockstream:new-indexfrom
EddieHouston:fix/mempool-conflict-reconciliation

Conversation

@EddieHouston

Copy link
Copy Markdown
Collaborator

Summary

Prevent submitted replacement transactions from temporarily coexisting with the transactions they replace in electrs' local mempool.

  • detect locally indexed transactions that spend the same prevouts as an incoming transaction or package
  • follow mempool spend edges to collect and remove all descendants of those conflicts
  • reconcile conflicts before mutating any indexes, while keeping the ownership-aware edge removal from fix(mempool): tolerate missing/foreign edges on eviction #234 as defense in depth
  • reject an internally conflicting incoming batch before insertion
  • cover both broadcast_raw and submit_package immediate-insertion paths through the shared Mempool::add() implementation

This prevents the inconsistent state tracked in #236, where txstore and history could contain two conflicting spenders while edges could represent only one.

Fixes #236

Tests

  • cargo test --test rest test_rest_mempool_rbf_reconciled -- --nocapture
  • cargo test --test rest -- --nocapture (26 passed)
  • cargo check --tests
  • cargo check --tests --features liquid

The REST regressions verify immediately after both raw and package broadcast—before the next periodic mempool sync—that the replaced transaction is absent and the replacement is queryable.

@EddieHouston
EddieHouston force-pushed the fix/mempool-conflict-reconciliation branch from 7b7b677 to 4356819 Compare August 27, 2026 15:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

add_by_txids not evicting replaced txs in submit_package

1 participant