Skip to content

fix(chain): backport PR#2240 - #2324

Open
LLFourn wants to merge 1 commit into
bitcoindevkit:release/chain-0.23.xfrom
LLFourn:backport-2240
Open

LLFourn wants to merge 1 commit into
bitcoindevkit:release/chain-0.23.xfrom
LLFourn:backport-2240

Conversation

@LLFourn

@LLFourn LLFourn commented Sep 24, 2026

Copy link
Copy Markdown
Collaborator

Description

It's a backport for the bdk_chain fix introduced by #2240. If you're interested in the original fix, check the original PR for discussion/rationale.

A tx whose anchors are all in blocks no longer in the best chain falls through to the leftover stage of CanonicalIter, which made it canonical as unconfirmed without checking last_evicted. So a tx that was confirmed, reorged out and then evicted stayed canonical forever.

Notes to the reviewers

This differs from #2240 in one way. #2240 adds TxNode::is_evicted(), but that relies on TxNode::last_evicted, which 0.23 doesn't have. Adding the field would break anyone who constructs TxNode with a struct literal (see the note on TxGraph::get_last_evicted). So this backport does the same last_seen/last_evicted check inline in CanonicalIter, using the existing TxGraph::get_last_evicted, and adds no new API. For the same reason it leaves out #2240's tx_node_is_evicted unit test.

#2240's end-to-end test test_evicted_stale_anchored_tx_not_canonical is ported to test_tx_graph.rs and uses list_canonical_txs, since canonical_view doesn't exist in 0.23. It fails without the fix.

Changelog notice

### Fixed

- Skip evicted transactions during leftover canonicalization, so a transaction anchored only in stale blocks is no longer canonical once it has been evicted.

Checklists

All Submissions:

Backport of bitcoindevkit#2240 to `release/chain-0.23.x`.

A tx whose anchors are all in stale blocks falls through to the leftover
stage of `CanonicalIter`, which marked it canonical without consulting
`last_evicted`. The eviction check is done inline here because 0.23's
`TxNode` has no `last_evicted` field and adding one would be breaking.

@noahjoeris noahjoeris left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK c211596

Thanks for the backport.
Unrelated: CI is broken and we need to update pinned deps

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

2 participants