Repository navigation
[coinselection] Increase SRD target by change_fee - #27846
Conversation
|
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. 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. |
|
Could we add a (fuzz) test that checks for this? |
I added an assert that SRD’s budget for change is always bigger than change_fee plus the dust amount for a P2WPKH output. This assert failed within seconds for the old code, but is fine with the new code. |
c0e40c4 to
a92efa9
Compare
There was a problem hiding this comment.
Answering myself. Dust limit for P2WPKH is 294 = (67 vbytes for input + 31 vbytes for output) * 3sat/vb
There was a problem hiding this comment.
But why use P2WPKH in particular, when change_output_size is a random int for 10 to 1000
There was a problem hiding this comment.
This parameter is the minimum viable change, which for this test, I think makes sense to actually be as high as possible, rather than dependent on the change output itself. The new behavior is that SRD will never make a change output that is smaller than CHANGE_LOWER, so I think it would make sense to set this to CHANGE_LOWER.
|
Approach ACK. That's a straightforward fix for the bug. |
a92efa9 to
05b0ce4
Compare
I discovered via fuzzing of another coin selection approach that at extremely high feerates SRD may find input sets that lead to transactions without change outputs. This is an unintended outcome since SRD is meant to always produce a transaction with a change output—we use other algorithms to specifically search for changeless solutions. The issue occures when the flat allowance of 50,000 ṩ for change is insufficient to pay for the creation of a change output with a non-dust amount, at and above 1,613 ṩ/vB. Increasing the change budget by change_fees makes SRD behave as expected at any feerates.
Adding this assert to the fuzz test without increasing the change target by the change_fee resulted in a crash within a few seconds.
05b0ce4 to
1771daa
Compare
|
Rebase: Increased minimum value of change to |
|
ACK 1771daa |
1 similar comment
|
ACK 1771daa |
I discovered via fuzzing of another coin selection approach that at extremely high feerates SRD may find input sets that lead to transactions without change outputs. This is an unintended outcome since SRD is meant to always produce a transaction with a change output—we use other algorithms to specifically search for changeless solutions. The issue occures when the flat allowance of 50,000 ṩ for change is insufficient to pay for the creation of a change output with a non-dust amount, at and above 1,613 ṩ/vB. Increasing the change budget by change_fees makes SRD behave as expected at any feerates. Github-Pull: bitcoin#27846 Rebased-From: 941b8c6
Adding this assert to the fuzz test without increasing the change target by the change_fee resulted in a crash within a few seconds. Github-Pull: bitcoin#27846 Rebased-From: 1771daa
I discovered via fuzzing of another coin selection approach that at extremely high feerates SRD may find input sets that lead to transactions without change outputs. This is an unintended outcome since SRD is meant to always produce a transaction with a change output—we use other algorithms to specifically search for changeless solutions.
The issue occurs when the flat allowance of 50,000 ṩ for change is insufficient to pay for the creation of a change output with a non-dust amount, at and above 1,613 ṩ/vB. Increasing the change budget by
change_feemakes SRD behave as expected at any feerates.Note: The intermittent failures of
test/functional/interface_usdt_mempool.pyare a known issue: #27380