Skip to content

[Review] Merge bitcoin/bitcoin#37011: test: fix input check of bumped tx in wallet_spend_unconfirmed.py - #2

Merged
jonatack merged 1 commit into
bitcoin-v:masterfrom
BTC4Peace:mirror/pr-0790f68d8671
Dec 1, 2026
Merged

jonatack merged 1 commit into
bitcoin-v:masterfrom
BTC4Peace:mirror/pr-0790f68d8671

Conversation

@auditbob

@auditbob auditbob Bot commented Nov 30, 2026

Copy link
Copy Markdown

Upstream commit: bitcoin/bitcoin@0790f68

5b43f22f18a652e16125d9382cee831fa4f3e9a6 test: fix input check of bumped tx in wallet_spend_unconfirmed.py (Sebastian Falbesoner)

Pull request description:

This PR fixes a small (likely copy-pasta) mistake in wallet_spend_unconfirmed.py (introduced in 2e35e94 / #26152): after bumping the fee, the test_rbf_bumping sub-test meant to check that the replacement transaction still has a single input spending from the unconfirmed parent, but mistakenly checked the original transaction again (which had already been checked before the bump).

ACKs for top commit:
l0rinc:
code review ACK 5b43f22f18a652e16125d9382cee831fa4f3e9a6
maflcko:
lgtm ACK 5b43f22f18a652e16125d9382cee831fa4f3e9a6

Tree-SHA512: d67baabc05cfcde195b637e8ea3755570f80c0af21eca285f778c5ac86c82e7e9243163996cf48ee598e4e049ebc56007fb26f30c26ccf180ae924bc45981e34


Mirrored from audited staging PR: BTC4Peace/bitcoin-agentic-workflow#42

…nd_unconfirmed.py

5b43f22 test: fix input check of bumped tx in wallet_spend_unconfirmed.py (Sebastian Falbesoner)

Pull request description:

  This PR fixes a small (likely copy-pasta) mistake in `wallet_spend_unconfirmed.py` (introduced in 2e35e94 / bitcoin#26152): after bumping the fee, the `test_rbf_bumping` sub-test meant to check that the replacement transaction still has a single input spending from the unconfirmed parent, but mistakenly checked the original transaction again (which had already been checked before the bump).

ACKs for top commit:
  l0rinc:
    code review ACK 5b43f22
  maflcko:
    lgtm ACK 5b43f22

Tree-SHA512: d67baabc05cfcde195b637e8ea3755570f80c0af21eca285f778c5ac86c82e7e9243163996cf48ee598e4e049ebc56007fb26f30c26ccf180ae924bc45981e34

Cherry-picked-from: bitcoin/bitcoin@0790f68
@auditbob

auditbob Bot commented Nov 30, 2026

Copy link
Copy Markdown
Author

I have verified the change and the relevant helper/bumpfee semantics. A few substantive corrections to both drafts.

Post-Merge Audit — 0790f68d (PR #37011, wallet_spend_unconfirmed.py)

1. Summary

One-line, test-only correction in test/functional/wallet_spend_unconfirmed.py inside UnconfirmedInputTest.test_rbf_bumping. At test/functional/wallet_spend_unconfirmed.py:327, the post-bump input assertion now consumes the replacement transaction bumped_ancestor_aware_tx (returned by wallet.gettransaction(txid=wallet.bumpfee(...)["txid"], verbose=True) at lines 325–326) instead of the already-asserted original ancestor_aware_tx (asserted at test/functional/wallet_spend_unconfirmed.py:318). Motivation: the previous line re-checked the pre-bump transaction, leaving the replacement's input set unverified. The file at the merge commit matches the diff: exactly one changed line, no other hunks, and assert_spends_only_parents is defined at test/functional/wallet_spend_unconfirmed.py:42 with 16 call sites, of which only line 327 passes a bumped tx.

2. Consensus & Validation

None. Test-only change; no src/ files touched, no impact on validation, script/tx/block checks, chainstate/UTXO set, or reorg behavior.

3. Security, P2P & DoS

None. No production code, serialization, or RPC surface modified. The change only activates one previously vacuous assertion, so it can only catch more wallet regressions (e.g. bumpfee failing to reuse the original outpoint), never mask them.

4. Concurrency & Locking

None. Sequential single-node RPC calls in a Python functional test; no cs_main/mempool/wallet locking involved.

5. Code Quality & Test Coverage

  • The assertion is now meaningful rather than automatically true: bumpfee in this scenario reuses the original single outpoint, so len(vin) == 1 plus "input txid is parent_txid" is the intended invariant, and it aligns with the ancestry set [parent_tx, bumped_ancestor_aware_tx] used by calc_set_fee_rate at test/functional/wallet_spend_unconfirmed.py:331–333, which already used the corrected variable.
  • [Nit] The stronger invariant asserted at line 327 is not actually a guarantee of bumpfee: src/wallet/feebumper.cpp:318 sets new_coin_control.m_allow_other_inputs = true (with m_min_depth = 1 at src/wallet/feebumper.cpp:321), so fee-bumping may pull in additional confirmed coins when change reduction is insufficient. In this test the change output is large (~0.5 BTC) and the feerate only doubles (30 → 60 sat/vB), so no extra input is added, and the wallet does hold spare confirmed coins — meaning the assertion is legitimately testing reuse rather than being trivially unfalsifiable. Still, the line is stricter than the RPC contract and could break if the funding amounts/feerates or coin selection heuristics change; that is an acceptable test-specific invariant, not a code defect.
  • [Nit] assert_spends_only_parents (test/functional/wallet_spend_unconfirmed.py:42–49) compares only vin[i]["txid"] against a checklist and never looks at vout. Since parent_txid here has two wallet-owned outputs, a hypothetical regression where bumpfee spent the other output of the same parent would still pass. Pre-existing, and duplicate-entry usage at test/functional/wallet_spend_unconfirmed.py:350 relies on txid-only matching, so tightening the helper to (txid, vout) pairs would require touching that call site.
  • All other assert_spends_only_parents call sites (lines 83, 103, 130, 158, 188, 217, 248, 270, 296, 350, 378, 405, 431, 456) pass ancestor_aware_tx in sub-tests that build exactly one child transaction, so no analogous copy-paste defect was found in this file.

6. Cross-Audit Reconciliation & Post-Merge Verdict

Both auditors agreed on the core conclusion — the fix makes the RBF sub-test assert on the replacement transaction and is correct/test-only — and I independently confirmed the changed line, the duplicate pre-bump assertion at line 318, the helper's txid-only comparison at lines 42–49, and the follow-on feerate assertions at lines 329–333.

Corrections applied:

  • Dropped as inaccurate: audit_a's claim that "bumpfee without options={"add_inputs": true} is not allowed to add new inputs". src/wallet/feebumper.cpp:318 explicitly permits additional inputs (m_allow_other_inputs = true); the single-input outcome here comes from ample change, not from an API restriction, so the new assertion is a test-scenario invariant rather than a protocol guarantee.
  • Downgraded to [Nit]: audit_a's "17 call sites" miscount (there are 16 calls plus the definition) and audit_b's implicit framing that bumpfee cannot add inputs. Both auditors' vout-blindness observation is verified and kept as a pre-existing [Nit].
  • Neither auditor cited an unverified/unobserved symbol; audit_b's description of parent_tx having two wallet outputs (spend + change from the 2 BTC funded UTXO) is consistent with setup_and_fund_wallet at lines 21–27 and the pattern used at line 348–350.

Overall risk level: negligible. No production behavior, consensus, P2P, or locking impact; the merge strictly strengthens an existing functional test.

Key lines to double-check: test/functional/wallet_spend_unconfirmed.py:318 and :327 (which transaction object each assertion receives), test/functional/wallet_spend_unconfirmed.py:42–49 (optional vout tightening), and src/wallet/feebumper.cpp:315–321 when reasoning about whether "same inputs after bump" is guaranteed.

Triage: routine


📊 Token Usage & Review Stats
Stage Model Input Tokens Cache Hit Output Reasoning Total Rounds Latency
Audit A deepseek-flash 19,930 10,624 (53%) 1,421 388 21,351 2 11.9s
Audit B gemini-4-neon-high 44,211 19,234 (44%) 2,300 1,317 46,511 2 27.9s
Judge deepseek-flash 70,187 55,552 (79%) 4,313 2,333 74,500 5 33.1s
Total — 134,328 85,410 (64%) 8,034 4,038 142,362 9 72.9s

@auditbob auditbob Bot added audited Automated review completed Tests labels Nov 30, 2026

@jonatack jonatack 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 20a49a1

@jonatack
jonatack merged commit 02337ba into bitcoin-v:master Dec 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

audited Automated review completed Tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant