Files
bitcoin/src/wallet/test
Ava Chow a5050ddb6b Merge bitcoin/bitcoin#32150: coinselection: Optimize BnB exploration
7249b376a0 opt: Skip UTXOs with worse waste, same eff_value (Murch)
5204291860 opt: Skip evaluation of equivalent input sets (Murch)
ba1807b981 coinselection: Track effective_value lookahead (Murch)
fa226ab902 coinselection: BnB skip exploring high waste (Murch)
7ecea1dc5d coinselection: Track whether BnB completed (Murch)
3ca0f36164 coinselection: rewrite BnB in CoinGrinder-style (Murch)
2e73739837 coinselection: Track BnB iteration count in result (Murch)

Pull request description:

  This PR rewrites the implementation of the BnB coinselection algorithm
  to skip the duplicate evaluation of previously visited input selections.

  In the original implementation of BnB, the state of the search is
  backtracked by explicitly walking back to the omission branch and then
  testing again. This retests an equivalent candidate set as before, e.g.,
  after backtracking from {ABC}, it would evaluate {AB_}, before trying
  {AB_D}, but {AB_} is equivalent to {AB} which was tested before.

  CoinGrinder tracks the state of the search instead by remembering which
  UTXO was last added and explicitly shifting from that UTXO directly to
  the next, so after {ABC}, it will immediately move on to {AB_D}. We
  replicate this approach here.

  As fewer nodes are visited, this approach will enumerate more possible
  combinations than the original implementation given the same limit for
  iterations.

ACKs for top commit:
  achow101:
    ACK 7249b376a0
  w0xlt:
    reACK 7249b376a0

Tree-SHA512: fd5851ceea3a3a4699fc062254fa5438daa4275b4d52325983e63670040cf0ba35112be9e63813d8f30b38993c031f3df343b2152eb8c068d272fbff72d1881a
2026-06-03 14:06:42 -07:00
..