-
Notifications
You must be signed in to change notification settings - Fork 37.7k
wallet: skip BnB when SFFO is enabled #28994
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
Conversation
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. Code CoverageFor detailed information about the code coverage, see the test coverage report. ReviewsSee the guideline for information on the review process.
If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update. 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 was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approach ACK: 233a07a
@@ -345,6 +348,7 @@ BOOST_AUTO_TEST_CASE(bnb_search_test) | |||
|
|||
CoinsResult available_coins; | |||
|
|||
coin_selection_params_bnb.m_effective_feerate = CFeeRate(0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: This test was already a bit weird to me, because it is categorized as belonging to "BnB", but the composition of preset inputs and the selection of additional inputs is a SelectCoins
-level functionality that has little to do with specific coin selection algorithms. Composability should be tested at SelectCoins
level (which it is in spend_tests
and wallet_fundrawtransaction.py
, although it could probably be more extensive). Since we already tested whether we can select two UTXOs that exactly match an amount in absence of fees above, I expect that we could remove this test altogether without losing coverage.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approach ACK
233a07a
to
7e1bf0d
Compare
Updated per feedback. Thanks everyone. Test wise; replaced the logs debugger approach for a low level function call (per #28994 (comment)). And applied |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! I am uncomfortable with adding the log message in a4c3294 as it has nothing to do with the bug fix and I think it could confuse (or worse, alarm) users to see "Waste" in their logs in the context of coin selection when waste is a not well-documented, implementation-specific term. Can we drop a4c3294 for now and revisit debug logging in a separate PR, unrelated to the v26 release?
Logs aren't meant for end users; logs are useful for us to understand what is going on internally. Debug issues and provide better feedback to our users. This is not different to what we do for the fee calculation. And there is more documentation about the selection waste than doc about each of the logged fee reasons actually. Right now, the transaction creation process lacks of outputting this information (thus why we are forced to call a low level function to test the bug). Moreover, as coin selection isn't a deterministic process, the lack of this info makes debugging and helping users harder than what it should. That being said, if you and others agree on removing the logging after reading the rationale I just wrote, could drop it too. I'm not that hard on it. |
Strongly disagree with this statement, and regardless of who they are intended for, users (people who run nodes) have access to these logs and do look at them.
This is irrelevant to my point that this is not a bug fix and shouldn't be included in a bug fix PR. I also don't agree with the justification and claim that coin selection is well-documented, but I'd rather leave that discussion for a PR related to improving wallet logging and keep this one focused on the bug fix for v26 :) |
Where did I claim that coin selection is well-documented? I said that it is more documented than fee estimation. And fee estimation is being logged.
Everyone have access. That doesn't mean that they are meant for everyone. Thus why we have logging domains and levels. Moreover, most logging domains are disabled by default. Including the wallet one. |
Sorry, my comment should say |
np. Happens on any convo. I'm not that strong on the new logging introduction, still, sharing the change rationale and opening the convo helps moving forward. |
7e1bf0d
to
efb54a2
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I realized that we need to add the input fee to each UTXO rather than deducting it from the target for the two input set options to have the same waste score.
Co-authored-by: furszy <matiasfurszyfer@protonmail.com>
Useful for understanding what is going on internally when the software is running. Debug issues, and provide more accurate feedback to users.
efb54a2
to
1d3bc77
Compare
Updated per feedback. Thanks. Note: Note 2: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACK 1d3bc77
Applied @murchandamus suggestion of adding inputs fee to each UTXO rather than deduct them from the target. The latter one was breaking the equivalence of the input sets.
Wasn't the test still passing before, when you were deducting them from the target? If so, I would suggest we take a closer look at this test in #28985 to ensure it's testing the thing it's supposed to be testing.
18669d7
to
576bee8
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add_coin(available_coins, *wallet, COIN + params.m_cost_of_change, /*feerate=*/params.m_effective_feerate, /*nAge=*/6, /*fIsFromMe=*/true, /*nInput=*/0, /*spendable=*/true); | ||
add_coin(available_coins, *wallet, 0.5 * COIN + params.m_cost_of_change, /*feerate=*/params.m_effective_feerate, /*nAge=*/6, /*fIsFromMe=*/true, /*nInput=*/0, /*spendable=*/true); | ||
add_coin(available_coins, *wallet, 0.5 * COIN, /*feerate=*/params.m_effective_feerate, /*nAge=*/6, /*fIsFromMe=*/true, /*nInput=*/0, /*spendable=*/true); | ||
// Knapsack will only find a changeless solution on an exact match to the satoshi, SRD doesn’t look for changeless | ||
// If BnB were run, it would produce a single input solution with the best waste score |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good, now I’d expect:
- SRD randomly returning two or three of the inputs
- Knapsack return { COIN+coc, 0.5×COIN }
- BnB return { COIN+coc }
Since the feerate is higher than the LFTR, two or three inputs with change are worse than one input without change, even when dropping coc into fees. Ergo, BnB not being the first solution proves that BnB wasn’t run.
ACK 576bee8 |
Yes, ACK 576bee8 |
ACK 576bee8 |
Co-authored-by: furszy <matiasfurszyfer@protonmail.com> Github-Pull: bitcoin#28994 Rebased-From: 5cea25b
Useful for understanding what is going on internally when the software is running. Debug issues, and provide more accurate feedback to users. Github-Pull: bitcoin#28994 Rebased-From: 0c57557
Verify the transaction creation process does not produce a BnB solution when SFFO is enabled. This is currently problematic because it could require a change output. And BnB is specialized on changeless solutions. Co-authored-by: Andrew Chow <achow101@gmail.com> Co-authored-by: Murch <murch@murch.one> Github-Pull: bitcoin#28994 Rebased-From: 05e5ff1
Github-Pull: bitcoin#28994 Rebased-From: 576bee8
Added this to #29011 for backporting to 26.x. |
See #28918 (comment). This doesn't seem to have fixed the fuzzer. |
It fixed the initially reported one (#28918 (comment)). The latest one is different. |
Co-authored-by: furszy <matiasfurszyfer@protonmail.com> Github-Pull: bitcoin#28994 Rebased-From: 5cea25b
Useful for understanding what is going on internally when the software is running. Debug issues, and provide more accurate feedback to users. Github-Pull: bitcoin#28994 Rebased-From: 0c57557
Verify the transaction creation process does not produce a BnB solution when SFFO is enabled. This is currently problematic because it could require a change output. And BnB is specialized on changeless solutions. Co-authored-by: Andrew Chow <achow101@gmail.com> Co-authored-by: Murch <murch@murch.one> Github-Pull: bitcoin#28994 Rebased-From: 05e5ff1
Github-Pull: bitcoin#28994 Rebased-From: 576bee8
7b79e54 doc: update release notes for 26.x (fanquake) ccf00b1 wallet: Fix use-after-free in WalletBatch::EraseRecords (MarcoFalke) 40252e1 ci: Set `HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK` to avoid failures (Hennadii Stepanov) b06b14e rpc: getwalletinfo, return wallet 'birthtime' (furszy) 1283401 test: coverage for wallet birth time interaction with -reindex (furszy) 0fa47e2 wallet: fix legacy spkm default birth time (furszy) 84f4a6c wallet: birth time update during tx scanning (furszy) 074296d refactor: rename FirstKeyTimeChanged to MaybeUpdateBirthTime (furszy) 35039ac fuzz: disable BnB when SFFO is enabled (furszy) 903b462 test: add coverage for BnB-SFFO restriction (furszy) 05d0576 wallet: create tx, log resulting coin selection info (furszy) 5493ebb wallet: skip BnB when SFFO is active (Murch) b15e2e2 test: add regression test for the getrawtransaction segfault (Martin Zumsande) 5097bb3 rpc: fix getrawtransaction segfault (Martin Zumsande) 81e744a ci: Use Ubuntu 24.04 Noble for asan (MarcoFalke) 69e53d1 ci: Use Ubuntu 24.04 Noble for tsan,tidy,fuzz (MarcoFalke) d2c80b6 doc: Missing additions to 26.0 release notes (fanquake) 8dc2c75 doc: add historical release notes for 26.0 (fanquake) Pull request description: Backports for `26.x`. Currently: * #28920 * #28992 * #28994 * #29003 * #29023 * #29080 * #29176 ACKs for top commit: TheCharlatan: ACK 7b79e54 glozow: ACK 7b79e54, matches mine Tree-SHA512: 898aec76ed3ad35e0edd0980af5bcc21bd60003bbf69e0b4f473ed2aa38c4e3b360b930bc3747cf798195906a8f9fe66417524f5e5ef40fa68f1c1aaceebdeb0
Solves #28918. Coming from #28918 (comment) discussion.
The intention is to decouple only the bugfix relevant commits from #28985, allowing them to be included in the 26.x release. This way, we can avoid disabling the coin selection fuzzing test for an entire release.
Note:
Have introduced few changes to the bug fix commit so that the unit tests pass without the additional burden introduced in #28985.