mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-06-02 17:24:58 +02:00
Merge bitcoin/bitcoin#28366: Fix waste calculation in SelectionResult
bd34dd85e7Use `exact_target` shorthand in coinselector_tests (Murch)7aa7e30441Fold GetSelectionWaste() into ComputeAndSetWaste() (Murch) Pull request description: PR #26152 moved waste calculation into SelectionResult to be able to correct the waste score on basis of the bump_fee_group_discount for overlapping ancestries. This left two functions with largely overlapping purpose, where one was simply a wrapper of the other. This PR cleans up the overlap, and fixes the double-meaning of `change_cost` where the `GetChange()` function assumed that no change was created when `change_cost` was set to 0. This behavior was exploited in a bunch of tests, but is problematic, because a `change_cost` of 0 is permitted with custom settings for feerate and discard_feerate (i.e. when they’re both 0). ACKs for top commit: achow101: ACKbd34dd85e7furszy: Code ACKbd34dd85e7ismaelsadeeq: Code Review ACKbd34dd85e7Tree-SHA512: 83a2688d45d719dc61a64b5180fe136107faccf401a59df65245c05d701748a03e85ed56fde8c9b7ef39a3ab54374dd3718c559bda5b3f55dafedfd7fed25161
This commit is contained in:
@@ -270,7 +270,7 @@ FUZZ_TARGET(coinselection)
|
||||
if (result_srd) {
|
||||
assert(result_srd->GetSelectedValue() >= target);
|
||||
assert(result_srd->GetChange(CHANGE_LOWER, coin_params.m_change_fee) > 0); // Demonstrate that SRD creates change of at least CHANGE_LOWER
|
||||
result_srd->ComputeAndSetWaste(coin_params.min_viable_change, coin_params.m_cost_of_change, coin_params.m_change_fee);
|
||||
result_srd->RecalculateWaste(coin_params.min_viable_change, coin_params.m_cost_of_change, coin_params.m_change_fee);
|
||||
(void)result_srd->GetShuffledInputVector();
|
||||
(void)result_srd->GetInputSet();
|
||||
}
|
||||
@@ -279,7 +279,7 @@ FUZZ_TARGET(coinselection)
|
||||
auto result_knapsack = KnapsackSolver(group_all, target, change_target, fast_random_context, MAX_STANDARD_TX_WEIGHT);
|
||||
if (result_knapsack) {
|
||||
assert(result_knapsack->GetSelectedValue() >= target);
|
||||
result_knapsack->ComputeAndSetWaste(coin_params.min_viable_change, coin_params.m_cost_of_change, coin_params.m_change_fee);
|
||||
result_knapsack->RecalculateWaste(coin_params.min_viable_change, coin_params.m_cost_of_change, coin_params.m_change_fee);
|
||||
(void)result_knapsack->GetShuffledInputVector();
|
||||
(void)result_knapsack->GetInputSet();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user