Merge bitcoin/bitcoin#31279: policy: ephemeral dust followups

466e4df3fb assert_mempool_contents: assert not duplicates expected (Greg Sanders)
ea5db2f269 functional: only generate required blocks for test (Greg Sanders)
d033acb608 fuzz: package_eval: let fuzzer run out input in main tx creation loop (Greg Sanders)
ba35a570c5 CheckEphemeralSpends: return boolean, and set child state and txid outparams (Greg Sanders)
cf0cee1617 func: add note about lack of 1P1C propagation in tree submitpackage (Greg Sanders)
8424290304 unit test: ephemeral_tests is using a dust relay rate, not minrelay (Greg Sanders)
d9cfa5fc4e CheckEphemeralSpends: no need to iterate inputs if no parent dust (Greg Sanders)
87b26e3dc0 func: rename test_free_relay to test_no_minrelay_fee (Greg Sanders)
e5709a4a41 func: slight elaboration on submitpackage restriction (Greg Sanders)
08e969bd10 RPC: only enforce dust rules on priority when standardness active (Greg Sanders)
ca050d12e7 unit test: adapt to changing MAX_DUST_OUTPUTS_PER_TX (Greg Sanders)
7c3490169c fuzz: package_eval: move last_tx inside txn ctor (Greg Sanders)
445eaed182 fuzz: use optional status instead of should_rbf_eph_spend (Greg Sanders)
4dfdf615b9 fuzz: remove unused TransactionsDelta validation interface (Greg Sanders)
09ce926e4a func: cleanup reorg test comment (Greg Sanders)
768a0c1889 func: cleanup test_dustrelay comments (Greg Sanders)
bedca1cb66 fuzz: Directly place transactions in vector (Greg Sanders)
c041ad6ecc fuzz: explain package eval coin tracking better (Greg Sanders)
bc0d98ea61 fuzz: remove dangling reference to GetEntry (Greg Sanders)
15b6cbf07f unit test: make dust index less magical (Greg Sanders)
5fbcfd12b8 unit test: assert txid returned on CheckEphemeralSpends failures (Greg Sanders)
ef94d84b4e bench: remove unnecessary CMTxn constructors (Greg Sanders)
c5c10fd317 ephemeral policy doxygen cleanup (Greg Sanders)
dd9044b8d4 ephemeral policy: IWYU (Greg Sanders)
c6859ce2de Move+rename GetDustIndexes -> GetDust (Greg Sanders)
62016b3230 Use std::ranges for ephemeral policy checks (Greg Sanders)
3ed930a1f4 Have HasDust and PreCheckValidEphemeralTx take CTransaction (Greg Sanders)
04a614bf9a Rename CheckValidEphemeralTx to PreCheckEphemeralTx (Greg Sanders)
cbf1a47d60 CheckEphemeralSpends: only compute txid of tx when needed (Greg Sanders)

Pull request description:

  Follow-up to https://github.com/bitcoin/bitcoin/pull/30239

  Here are the parent PR's comments that should be addressed by this PR:

  https://github.com/bitcoin/bitcoin/pull/30239/files#r1834529646
  https://github.com/bitcoin/bitcoin/pull/30239/files#r1831247308
  https://github.com/bitcoin/bitcoin/pull/30239/files#r1832622481
  https://github.com/bitcoin/bitcoin/pull/30239/files#r1831195216
  https://github.com/bitcoin/bitcoin/pull/30239#discussion_r1835805164
  https://github.com/bitcoin/bitcoin/pull/30239#discussion_r1835805164
  https://github.com/bitcoin/bitcoin/pull/30239#discussion_r1834639096
  https://github.com/bitcoin/bitcoin/pull/30239#discussion_r1834624976
  https://github.com/bitcoin/bitcoin/pull/30239#discussion_r1834619709
  https://github.com/bitcoin/bitcoin/pull/30239#discussion_r1834610434
  https://github.com/bitcoin/bitcoin/pull/30239#discussion_r1834504436
  https://github.com/bitcoin/bitcoin/pull/30239#discussion_r1834500036
  https://github.com/bitcoin/bitcoin/pull/30239#discussion_r1832985488
  https://github.com/bitcoin/bitcoin/pull/30239#discussion_r1830929809
  https://github.com/bitcoin/bitcoin/pull/30239#discussion_r1832376920
  https://github.com/bitcoin/bitcoin/pull/30239#discussion_r1832755799
  https://github.com/bitcoin/bitcoin/pull/30239#discussion_r1832492686
  https://github.com/bitcoin/bitcoin/pull/30239#discussion_r1832980576
  https://github.com/bitcoin/bitcoin/pull/30239#discussion_r1832784278
  https://github.com/bitcoin/bitcoin/pull/30239#discussion_r1837989979
  https://github.com/bitcoin/bitcoin/pull/30239#discussion_r1830996993
  https://github.com/bitcoin/bitcoin/pull/30239#discussion_r1830997947
  https://github.com/bitcoin/bitcoin/pull/30239#discussion_r1830012890
  https://github.com/bitcoin/bitcoin/pull/30239#discussion_r1830037288
  https://github.com/bitcoin/bitcoin/pull/30239#discussion_r1830977092
  https://github.com/bitcoin/bitcoin/pull/30239#discussion_r1832622481
  https://github.com/bitcoin/bitcoin/pull/30239#discussion_r1834726168
  https://github.com/bitcoin/bitcoin/pull/30239#discussion_r1832453654
  https://github.com/bitcoin/bitcoin/pull/30239#discussion_r1848488226

ACKs for top commit:
  naumenkogs:
    ACK 466e4df3fb
  hodlinator:
    ACK 466e4df3fb
  theStack:
    lgtm ACK 466e4df3fb
  glozow:
    utACK 466e4df3fb

Tree-SHA512: 89106f695755c238b84e0996b89446c0733e10a94c867f656d516d26697d2efe38dfc332188b8589a0a26a3d2bd2c88c6ab70c108e187ce5bfcb91bbf3fb0391
This commit is contained in:
glozow
2024-11-25 13:47:31 -05:00
15 changed files with 210 additions and 146 deletions

View File

@@ -78,8 +78,8 @@ class DustRelayFeeTest(BitcoinTestFramework):
assert_equal(self.nodes[0].getrawmempool(), [])
# Double dust, both unspent, with fees. Would have failed individual checks.
# Dust is 1 satoshi create_self_transfer_multi disallows 0
# Create two dust outputs. Transaction has zero fees. both dust outputs are unspent, and would have failed individual checks.
# The amount is 1 satoshi because create_self_transfer_multi disallows 0.
dusty_tx = self.wallet.create_self_transfer_multi(fee_per_output=1000, amount_per_output=1, num_outputs=2)
dust_txid = self.nodes[0].sendrawtransaction(hexstring=dusty_tx["hex"], maxfeerate=0)

View File

@@ -61,7 +61,7 @@ class EphemeralDustTest(BitcoinTestFramework):
self.test_non_truc()
self.test_unspent_ephemeral()
self.test_reorgs()
self.test_free_relay()
self.test_no_minrelay_fee()
def test_normal_dust(self):
self.log.info("Create 0-value dusty output, show that it works inside truc when spent in package")
@@ -363,7 +363,7 @@ class EphemeralDustTest(BitcoinTestFramework):
self.nodes[0].invalidateblock(block_res["hash"])
assert_mempool_contents(self, self.nodes[0], expected=[dusty_tx["tx"]], sync=False)
# Also should happen if dust is swept
# Should re-enter if dust is swept
sweep_tx_2 = self.wallet.create_self_transfer_multi(fee_per_output=0, utxos_to_spend=dusty_tx["new_utxos"], version=3)
self.add_output_to_create_multi_result(sweep_tx_2)
assert_raises_rpc_error(-26, "min relay fee not met", self.nodes[0].sendrawtransaction, sweep_tx_2["hex"])
@@ -401,7 +401,7 @@ class EphemeralDustTest(BitcoinTestFramework):
self.sync_all()
# N.B. this extra_args can be removed post cluster mempool
def test_free_relay(self):
def test_no_minrelay_fee(self):
self.log.info("Test that ephemeral dust works in non-TRUC contexts when there's no minrelay requirement")
# Note: since minrelay is 0, it is not testing 1P1C relay
@@ -462,15 +462,17 @@ class EphemeralDustTest(BitcoinTestFramework):
# Sweeps all dust, where all dusty txs are already in-mempool
sweep_tx = self.wallet.create_self_transfer_multi(fee_per_output=25000, utxos_to_spend=all_parent_utxos, version=2)
# N.B. Since we have multiple parents these are not propagating via 1P1C relay.
# minrelay being zero allows them to propagate on their own.
res = self.nodes[0].submitpackage([dusty_tx["hex"] for dusty_tx in dusty_txs] + [sweep_tx["hex"]])
assert_equal(res['package_msg'], "success")
assert_mempool_contents(self, self.nodes[0], expected=[dusty_tx["tx"] for dusty_tx in dusty_txs] + [sweep_tx["tx"], cancel_sweep["tx"]])
self.generate(self.nodes[0], 25)
self.generate(self.nodes[0], 1)
self.wallet.rescan_utxos()
assert_equal(self.nodes[0].getrawmempool(), [])
# Other topology tests require relaxation of submitpackage topology
# Other topology tests (e.g., grandparents and parents both with dust) require relaxation of submitpackage topology
self.restart_node(0, extra_args=[])
self.restart_node(1, extra_args=[])

View File

@@ -30,6 +30,7 @@ def assert_mempool_contents(test_framework, node, expected=None, sync=True):
test_framework.sync_mempools()
if not expected:
expected = []
assert_equal(len(expected), len(set(expected)))
mempool = node.getrawmempool(verbose=False)
assert_equal(len(mempool), len(expected))
for tx in expected: