Repository navigation
Conversation
The lambda inside CWallet::AbandonTransaction asserts that no
descendant of the transaction being abandoned is confirmed or in
the mempool. This is a consensus-level invariant, but the assertion
runs against the wallet's in-memory per-tx state, which can
transiently diverge from the chain -- e.g. during a reorganisation,
or when RBF candidates share inputs and end up linked to the same
parent output via mapTxSpends.
When that divergence is reached the assertion aborts the node.
Replace it with a graceful TxUpdate::UNCHANGED early-return,
preserving the behavioural intent ("do not abandon a confirmed or
mempool descendant") while no longer crashing. This mirrors how the
same lambda already handles isBlockConflicted and isAbandoned
descendants, and how the lambdas in MarkConflicted,
transactionAddedToMempool and transactionRemovedFromMempool handle
unexpected state.
Halting the recursion at the inconsistent descendant is the safe
choice: we cannot know whether the descendant's recorded children
belong to the same chain that confirmed it, so propagating the
abandonment further could compound the inconsistency.
Fixes bitcoin#34599
|
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. ReviewsSee the guideline for information on the review process. ConflictsReviewers, this pull request conflicts with the following ones:
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first. |
|
There is a root issue that is not being handled in this pr which is that a child transaction cannot be confirmed if the parent is unconfirmed. This may solve the specific assertion failure here but it leaves the transactions in inconsistent state in the wallet |
|
Thanks for reading. You're right that on-chain a child can't be confirmed while its parent is unconfirmed, but I think the "inconsistent state" here is narrower than it looks.
The early-return halts the walk at that descendant without mutating it, which is the same shape the sibling descendant-walk lambdas in A root-cause fix would mean either making |
|
This PR looks LLM generated, without real understanding from the author. LLM generated unit tests are not great for proving the existence of bugs, as LLMs can abuse the access to internal state to produce the wanted results. Please write a functional test that demonstrates the bug, as that would at least increase the confidence in the LLMs analysis. |
|
The assertion exists for a reason, and this PR does not demonstrate why the assumption for that assertion is incorrect. Unit tests can call things out of order and misuse APIs, it does not sufficiently show why the assumptions are incorrect. I'm going to close this PR as it is clearly LLM generated and there is no evidence that the author understands the mechanism of the issue. |
Fixes #34599.
CWallet::AbandonTransactionwalks the abandoned tx's descendantsvia
mapTxSpendsand asserts that none of them is confirmed or inthe mempool. That holds at the consensus level — if the parent isn't
in the chain, no child can be — but the assertion runs against the
wallet's in-memory per-tx state, which can transiently diverge:
individually and intermediate states are observable;
outpoint via
mapTxSpendsand so end up linked to the same parentoutput even though only one of them is the "real" descendant.
When the divergence is hit, the node aborts. The fix replaces the
two
assertcalls with aTxUpdate::UNCHANGEDearly-return so therecursion safely halts at the inconsistent descendant instead of
crashing — preserving the original intent ("don't abandon something
that's confirmed or in mempool") and matching the no-assert pattern
already used by the sibling lambdas in
MarkConflicted,transactionAddedToMempoolandtransactionRemovedFromMempool.A new
wallet_tests/abandon_with_confirmed_descendantunit testsynthesises the inconsistency (parent
TxStateInactive, childTxStateConfirmedlinked viamapTxSpends) and exercises theassertion site directly: pre-fix it aborts, post-fix
AbandonTransactionreturnstrue, marks the parent abandoned andleaves the child untouched.
Precedent: PR #31757 / commit 9ef429b fixed an analogous wallet
assertion crash on double block disconnection by handling the
inconsistent-state case rather than relying on the assertion.