Repository navigation
test: SRD tie-break test - #36740
test: SRD tie-break test#36740Zeegaths wants to merge 1 commit into
Conversation
|
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. External sites
ReviewsSee the guideline and AI policy for information on the review process.
If your review is incorrectly listed, please copy-paste 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. |
6d4730f to
3ed719d
Compare
|
Concept ACK. PR 33223 added a tie breaker condition such that if two UTXOs are the same effective_value, sort such that the lighter UTXO is preferred. This creates a lighter and thus cheaper transaction. The sort is defined by 33223 here: class MinOutputGroupComparator
{
public:
int operator() (const OutputGroup& group1, const OutputGroup& group2) const
{
return descending_effval_weight(group1, group2);
}
};However, the test added did not actually test the new behavior since selecting two UTXOs needed to hit the target did not cause an eviction to take place. Confirmed that this PR fixes that by lowering the weight limit which causes the heap to pop an item, and in so doing, must sort and then perform the eviction. The second lighter UTXO is added such that the only solution that causes completion is when both lighter UTXOs remain and the heavier UTXOs evicted. Approach ACK |
87756e7 to
2ade73d
Compare
|
noted, Thanks for this |
|
ACK 2ade73d |
Zippo76
left a comment
There was a problem hiding this comment.
tACK 2ade73d
Tested on macOS 27.0.1 arm64, using master fcf76ea549 for comparison. srd_test passes on the PR.
With the comparator change from #33223 reverted, the PR’s test fails while master’s test passes.
I also checked that the 536 WU limit only allows the two lighter coins together. Whenever a heavier coin makes the selection exceed that limit, it must be evicted for selection to succeed.
|
@Zeegaths please write your pull request descriptions in your own words. Not doing so is in violation of our AI policy. Most of the lines are basically redundant statements. Reviewers are expected to know basic git usage, how to run the tests and make them fail by undoing prior work, and read a diff to figure out which tests are changed. What it should say is why the change is important to you. |
i see what you mean. lmk if that works |
It does read a bit better. I think people can count for themselves how many tests are being run though. |
got it, thankyou |
Note that this is a non-deterministic code path being tested. It looks like because of issue 1) it would never fail if 33223 is revered. However, I think 2) may fail if 33223 is undone and the random selection happened to select the lighter coin on it's first attempt even with no eviction, although this is very unlikely. |
noted |
2ade73d to
b1240a8
Compare
When you force push like this it dismisses the reviews people have done. And if you don't explain why you are force pushing, it requires people to need to re-review all changes. Is this just a rebase? If so, it's nice to say that so people reviewing save time trying to figure out what changed. |
yes, It's just a rebase |
|
ACK b1240a8 |
The test in bitcoin#33223 builds `mixed_weight_pool` but passes `utxo_pool` to `TestSRDSuccess`, and the max weight (804 WU) fits any two coins, so SRD never evicts and the tie-break never runs. Pass `mixed_weight_pool` instead of `utxo_pool`. add an extra light coin and lower the max weight to 536 WU so that the heavier coin gets evicted on every tie. asserts the resulting utxos on success.
b1240a8 to
751956e
Compare
|
ACK 751956e CI looks like its down, however tests pass locally. |
frankomosh
left a comment
There was a problem hiding this comment.
reACK 751956e . Only change is switching to the TestSRDSuccess helper.

I was researching coin selection when I came across this bug, so I thought I'd fix it
Pr #33223 adjusts weight selection to keep the lighter coin when two coins have the same value, but the test has two mistakes, as confirmed in this comment
mixed_weight_poolbut passesutxo_pooltoTestSRDSuccess.4 * 3 * 67= 804 WU) fits any two coins (544 WU)If you reverse #33223, it still passes, which means it misses the tie-break
The fix
The test now uses `mixed_weight_pool and adds an extra light coin so that only two light coins can fit together and evicts a coin on every tie to pass.
Lowers the max weight to 536 WU; SRD now has to evict the heavier coin on every tie to succeed
This should show failed tests with bitcoin#33223 reverted and pass on master.