Repository navigation
test: add coverage for dust mempool policy (-dustrelayfee setting) - #26631
Conversation
This is needed in the next commit to calculate the dust threshold for a given output script and min feerate for defining dust.
|
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. Coverage
Updated at: 2022-12-16T12:29:44.053355. |
b3ba31a to
2c697dd
Compare
LarryRuane
left a comment
There was a problem hiding this comment.
ACK 2c697ddcb1fa4d04f55b024c06116530d7e74598
suggestions are non-blocking
There was a problem hiding this comment.
maybe add a comment before this definition:
# Equivalent to: CScript::IsWitnessProgram()|
Tested ACK |
pablomartin4btc
left a comment
There was a problem hiding this comment.
I think this statement is very useful as a context for the review:
The concept of dust was first introduced in PR #2577. This commit from PR #9380 introduced the -dustrelayfee option. Previous to that PR, the dust feerate was whatever -minrelaytxfee was set to.
Taken from the notes of the review club. Is it possible to add the label "Review club" to this PR please?
2c697dd to
d6fc1d6
Compare
|
Force-pushed with most suggestions taken, and another few changes:
Thanks for researching! 👍 I added this paragraph to the PR description, as it is very helpful for reviewers getting deeper into the topic of dust with some historical context.
+1 |
add coverage for dust mempool policy (-dustrelayfee setting) bitcoin/bitcoin#26631
| (script_to_p2wsh_script(CScript([OP_TRUE])), "P2WSH"), | ||
| (output_key_to_p2tr_script(pubkey[1:]), "P2TR"), | ||
| # witness programs for segwitv2+ can be between 2 and 40 bytes | ||
| (program_to_witness_script(2, b'\x66' * 2), "P2?? (future witness version 2)"), |
There was a problem hiding this comment.
As I do in #26875 could check v1 at non-32-byte-push lengths as well to make sure they're treated as UNKNOWN
| def set_test_params(self): | ||
| self.num_nodes = 1 | ||
|
|
||
| def test_dust_output(self, node: TestNode, dust_relay_fee: Decimal, |
There was a problem hiding this comment.
the node argument may be residue from when the PR used multiple nodes to test different configurations?
| tx_size = len(CTxOut(nValue=0, scriptPubKey=output_script).serialize()) | ||
| tx_size += 67 if output_script.IsWitnessProgram() else 148 | ||
| dust_threshold = int(get_fee(tx_size, dust_relay_fee) * COIN) | ||
| self.log.info(f"-> Test {type_desc} output (size {len(output_script)}, limit {dust_threshold})") |
There was a problem hiding this comment.
nit: I've been thinking about ways to formalize the way logging is done in the testing framework and indentation of subcases is in there. The ideal scenario would be for those things to happen automatically, but working with what we have...
I would like to make a minor suggestion that I believe makes the logging more readable:
| self.log.info(f"-> Test {type_desc} output (size {len(output_script)}, limit {dust_threshold})") | |
| self.log.info(f" - Test {type_desc} output (size {len(output_script)}, limit {dust_threshold})") |
and to remove even more noise:
| self.log.info(f"-> Test {type_desc} output (size {len(output_script)}, limit {dust_threshold})") | |
| self.log.info(f"- output (size {len(output_script)}, limit {dust_threshold})") |
I've noticed that this is a format that you have previously used in wallet_fast_rescan.py, but "- ..." is currently used in more place, such as rpc_decodescript.py and rpc_psbt.py and I believe that following the same format across the testing framework is for the better.
|
ACK d6fc1d6 |



This PR adds missing test coverage for the
-dustrelayfeesetting, which specifies the fee-rate used to define dust. Output scripts for all common types that are treated as standard by default (P2PK, P2(W)PKH, P2(W)SH, P2TR, bare multisig, null data, unknown witness versions v2+) are created and then checked for dust-mempool-policy each via thetestmempoolacceptRPC: a tx with an output's nValue equal to the dust threshold should be accepted, one with an nValue of just one 1 satoshi below that should be rejected with reasondust. This is repeatedly done for a fixed (but obviously somewhat arbitrary) list of different-dustrelayfeesettings on a single node, including the default and zero (i.e. no dust limit) settings.Note that the first commit introduces a necessary
CScripthelper methodIsWitnessProgram(using PascalCase in Python is likely controversial; in this case the style for the already existing methodGetSigOpCountwas followed, which also refers to a method in the coreCScriptclass).Some historical information about dust, contributed by pablomartin4btc:
"The concept of dust was first introduced in #2577. This commit from #9380 introduced the -dustrelayfee option. Previous to that PR, the dust feerate was whatever -minrelaytxfee was set to."