Skip to content

IndexedTxGraph: Transactions that conflict with relevant txs are also relevant. #2008

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

evanlinjin
Copy link
Member

@evanlinjin evanlinjin commented Aug 2, 2025

Description

This PR changes the behavior of IndexedTxGraph insert-if-relevant methods to consider relevant-tx-conflicts as relevant.

Affected methods:

  • .apply_block_relevant
  • .batch_insert_relevant
  • .batch_insert_relevant_unconfirmed

Rationale

It is useful to be able to determine:

  • Why something is no longer part of the best history.
  • Whether it is possible that that something can reappear in the best history.

In order to do this, we need to track conflicts of spk-relevant transactions.

For example, an incoming transaction may be evicted from the mempool due to insufficient fees or cancelled (a conflicting transaction is confirmed). The caller may want to handle these two possibilities differently:

  • Transaction has insufficient fees - the caller may want to CPFP the transaction.
  • Transaction is cancelled/replaced - The user may want to forget about this transactions once the conflict reaches x confirmations.

The IntentTracker will make use of these relevant-conflicts to help determine the course of action.

Side note about chain sources

For some chain sources, obtaining relevant-conflicts is extremely costly or downright impossible (i.e. Electrum, BIP-158 filters).

bdk_bitcoind_rpc::Emitter is still the most robust chain source to use.

Changelog notice

Changed:
- Behavior of `IndexedTxGraph` methods (`apply_block_relevant`, `batch_insert_relevant` and `batch_insert_relevant_unconfirmed`) to also consider conflicts of spk-relevant transactions as relevant.

Checklists

All Submissions:

New Features:

  • I've added tests for the new feature
  • I've added docs for the new feature

Change behavior of {insert|apply}-if-relevant methods of `IndexedTxGraph`
to also consider txs that conflict with relevant txs as relevant.

Rationale:

It is useful to determine why something is evicted from the mempool.

For example, an incoming transaction may be evicted from the mempool due
to insufficient fees or a conflicting transaction is confirmed.

* Insufficient fees - the user may want to CPFP the tx.
* Conflicting tx is confirmed - the sender probably purposefully
  cancelled the tx. The user may want to forget about this tx once it
  reaches x confirmations.

The `IntentTracker` will make use of these relevant-conflicts.

A note about chain sources:

For some chain sources, obtaining relevant-conflicts is extremely
costly or downright impossible (i.e. Electrum, BIP-158 filters).

`bdk_bitcoind_rpc::Emitter` is still the most robust chain source to use.
@evanlinjin evanlinjin self-assigned this Aug 2, 2025
@evanlinjin evanlinjin marked this pull request as ready for review August 2, 2025 09:22
@evanlinjin evanlinjin moved this to Needs Review in BDK Chain Aug 2, 2025
@evanlinjin evanlinjin requested review from LagginTimes, ValuedMammal and nymius and removed request for ValuedMammal August 3, 2025 13:24
@ValuedMammal
Copy link
Collaborator

Concept ACK

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Needs Review
Development

Successfully merging this pull request may close these issues.

2 participants