Skip to content
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

Further improve unconfirmed tx conflict resolution #1102

Closed
evanlinjin opened this issue Aug 29, 2023 · 2 comments · Fixed by #1109
Closed

Further improve unconfirmed tx conflict resolution #1102

evanlinjin opened this issue Aug 29, 2023 · 2 comments · Fixed by #1109
Labels
new feature New feature or request
Milestone

Comments

@evanlinjin
Copy link
Member

Describe the enhancement

At the end of ticket #1063's description, there is a Further work section which states:

Our current structures do not handle unconfirmed conflicts properly when the conflicting transactions have the same last_seen timestamp (thanks to @rajarshimaitra for pointing this out).

// FIXME: Currently both the mempool tx are indexed and listed out. This can happen in case of RBF fee bumps,
// when both the txs are observed at a single sync time. This can be resolved by checking the input's nSequence.
// Additionally in case of non RBF conflicts at same `seen_at`, conflicting txids can be reported back for filtering
// out in higher layers. This is similar to what core rpc does in case of unresolvable conflicts.

I propose we deal with this as follows:

When two unconfirmed txs conflict, but have the same last_seen, we can check the input's sequences (using RBF rules). Otherwise, we sort by feerate (if possible). We fallback to lexicographical sorting of txids.

@evanlinjin evanlinjin added the new feature New feature or request label Aug 29, 2023
@notmandatory notmandatory added this to BDK Aug 29, 2023
@notmandatory notmandatory moved this to Todo in BDK Aug 29, 2023
@LLFourn
Copy link
Contributor

LLFourn commented Aug 31, 2023

@evanlinjin I don't understand how do we fall back to checking the input's nsequence?

I would not use RBF flagging since it isn't even being enforced anymore by lots of miners: https://lists.linuxfoundation.org/pipermail/bitcoin-dev/2023-August/021890.html

Check if one tx has a higher absolute fee and feerate and then choose that one. If they can't be distinguished using this rule then I would just report one arbitrarily. Reporting both transactions as conflicted sounds like it could be useful. I'm not sure how this would bubble up to filter_chain_unspents.

@evanlinjin
Copy link
Member Author

@LLFourn I agree that we should just base it on fee/feerate only (so no nsequence).

The root of the problem would be in get_chain_position, which would bubble up to filter_chain_unspents, list_chain_txs, etc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new feature New feature or request
Projects
Archived in project
3 participants