functional test: Additional package evaluation coverage #31152

pull instagibbs wants to merge 1 commits into bitcoin:master from instagibbs:2024-10-submitpackage_evict_cpfp_success changing 1 files +95 −0
  1. instagibbs commented at 7:14 pm on October 24, 2024: member

    Current test coverage doesn’t ensure that mempool trimming doesn’t appear prior to the entire package, and not just the subpackage, is finished being submitted.

    Add a scenario that covers this case, where package ancestors can make it in individually, but would be immadiately evicted if not for the package CPFP.

    in response to #31122 (review) where if applied onto that PR’s old commit, the test fails due to package failure.

  2. DrahtBot commented at 7:14 pm on October 24, 2024: contributor

    The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

    Code Coverage

    For detailed information about the code coverage, see the test coverage report.

    Reviews

    See the guideline for information on the review process.

    Type Reviewers
    ACK rkrux, sdaftuar, glozow

    If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update.

    Conflicts

    Reviewers, this pull request conflicts with the following ones:

    • #28676 ([WIP] Cluster mempool implementation by sdaftuar)

    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.

  3. laanwj added the label Tests on Oct 24, 2024
  4. in test/functional/mempool_limit.py:121 in 3d66eab056 outdated
    116+        package_hex = []
    117+        # UTXOs to be spent by the ultimate child transaction
    118+        parent_utxos = []
    119+
    120+        # Series of parents that don't need CPFP and are submitted individually. Each one is large and
    121+        # belo, which means they should trigger eviction, but child submission should result
    


    sdaftuar commented at 11:36 pm on October 24, 2024:
    “belo”?

    instagibbs commented at 11:55 pm on October 24, 2024:
    incomplete sent, fixed
  5. in test/functional/mempool_limit.py:147 in 3d66eab056 outdated
    142+
    143+        # Create a child spending everything with an insane fee, bumping the package above mempool_entry_minrate
    144+        child = self.wallet.create_self_transfer_multi(utxos_to_spend=parent_utxos, fee_per_output=10000000)
    145+        package_hex.append(child["hex"])
    146+
    147+        # Package should be submitted, temporarily exceeding maxmempool, and then  evicted.
    


    sdaftuar commented at 11:44 pm on October 24, 2024:
    This comment isn’t right, is it? We don’t expect the package to be evicted?

    instagibbs commented at 11:55 pm on October 24, 2024:
    fixed thanks
  6. sdaftuar approved
  7. sdaftuar commented at 11:46 pm on October 24, 2024: member
    Looks good, just some comment nits.
  8. instagibbs force-pushed on Oct 24, 2024
  9. sdaftuar commented at 0:16 am on October 25, 2024: member
    ACK b318959bf8c2b9b02f718649adec03f7e07ac79d
  10. in test/functional/mempool_limit.py:108 in b318959bf8 outdated
    103+
    104+        mempool_txids = node.getrawmempool()
    105+        mempool_entries = [node.getmempoolentry(entry) for entry in mempool_txids]
    106+        fees_btc_per_kvb = [entry["fees"]["base"] / (Decimal(entry["vsize"]) / 1000) for entry in mempool_entries]
    107+        #mempool_maxrate = max(fees_btc_per_kvb)
    108+        #mempool_maxrate = mempool_maxrate.quantize(Decimal("0.00000000"))
    


    glozow commented at 0:43 am on October 25, 2024:
    forgot to delete?

    instagibbs commented at 1:23 pm on October 25, 2024:
    deleted
  11. in test/functional/mempool_limit.py:131 in b318959bf8 outdated
    128+
    129+        big_parent_txids = []
    130+        big_parent_wtxids = []
    131+        for i in range(num_big_parents):
    132+            # Last parent is higher feerate causing other parents to be possibly
    133+            # be evicted if trimming was allowed, which would cause the package to end up failing
    


    glozow commented at 0:44 am on October 25, 2024:

    nit: to be possibly be

    0            # Last parent is higher feerate causing other parents to possibly
    1            # be evicted if trimming was allowed, which would cause the package to end up failing
    

    instagibbs commented at 1:23 pm on October 25, 2024:
    fixed
  12. in test/functional/mempool_limit.py:173 in b318959bf8 outdated
    168+            assert txid in resulting_mempool_txids
    169+
    170+        # Check every evicted tx was higher feerate than parents which evicted it
    171+        eviction_set = set(mempool_txids) - set(resulting_mempool_txids) - set(big_parent_txids)
    172+        parent_entries = [node.getmempoolentry(entry) for entry in big_parent_txids]
    173+        max_parent_feerate = max([entry["fees"]["base"] / (Decimal(entry["vsize"]) / 1000) for entry in parent_entries])
    


    glozow commented at 1:07 am on October 25, 2024:

    nit: strictly speaking…

    0        max_parent_feerate = max([entry["fees"]["modified"] / (Decimal(entry["vsize"]) / 1000) for entry in parent_entries])
    

    instagibbs commented at 1:23 pm on October 25, 2024:
    changed in both places
  13. in test/functional/mempool_limit.py:96 in b318959bf8 outdated
    91+
    92+        # Clear mempool so it can be filled with minrelay txns
    93+        self.restart_node(0, extra_args=self.extra_args[0] + ["-persistmempool=0"])
    94+        assert_equal(node.getrawmempool(), [])
    95+
    96+        # Restarting the node resets mempool minimum feerate
    


    glozow commented at 1:13 am on October 25, 2024:
    nit: relying on the fact that mempool min feerate isn’t persisted seems a little bit brittle.

    instagibbs commented at 1:23 pm on October 25, 2024:
    If someone opens a PR to persist I’ll push for an RPC to set it explicitly :)
  14. in test/functional/mempool_limit.py:154 in b318959bf8 outdated
    149+        with node.assert_debug_log(expected_msgs=["rolling minimum fee bumped"]):
    150+            package_res = node.submitpackage(package=package_hex, maxfeerate=0)
    151+
    152+        assert_equal(package_res["package_msg"], "success")
    153+
    154+        # If intra-packing trimming ends up happening anyways, we would
    


    glozow commented at 1:18 am on October 25, 2024:
    Comment could be clearer: This test is specifically trying to test that intra-package trimming isn’t happening. We already know that a transaction with a high feerate descendant shouldn’t be evicted; we specifically want to make sure that the eviction decision doesn’t happen until the package is all the way in. So we check effective-includes to ensure that the transactions were evaluated separately.

    instagibbs commented at 1:23 pm on October 25, 2024:
    tried rephrasing
  15. glozow commented at 1:20 am on October 25, 2024: member
    ACK b318959bf8c2b9b02f718649adec03f7e07ac79d, tested that adding a trim at the end of subpackage evaluation causes this to fail. Happy to reack if you take the nits.
  16. in test/functional/mempool_limit.py:172 in b318959bf8 outdated
    166+        assert child["txid"] in resulting_mempool_txids
    167+        for txid in big_parent_txids:
    168+            assert txid in resulting_mempool_txids
    169+
    170+        # Check every evicted tx was higher feerate than parents which evicted it
    171+        eviction_set = set(mempool_txids) - set(resulting_mempool_txids) - set(big_parent_txids)
    


    rkrux commented at 12:22 pm on October 25, 2024:

    - set(big_parent_txids)

    I suppose this can be dropped based on the assertion above on lines 167/8?big_parent_txids is already in resulting_mempool_txids .


    instagibbs commented at 1:23 pm on October 25, 2024:
    a little bit of test redundancy that makes it more readable imo? leaving as is

    rkrux commented at 2:58 pm on October 25, 2024:
    Aah I see, the size of big_parent_txids is only 3 - I guess it won’t be an issue perf wise.
  17. functional test: Additional package evaluation coverage
    Current test coverage doesn't ensure that mempool trimming
    doesn't appear prior to the entire package, and not just
    the subpackage, is finished being submitted.
    
    Add a scenario that covers this case, where package
    ancestors can make it in individually, but would be
    immadiately evicted if not for the package CPFP.
    f32c34d0c3
  18. instagibbs force-pushed on Oct 25, 2024
  19. in test/functional/mempool_limit.py:124 in f32c34d0c3
    119+        # which means in aggregate they could trigger eviction, but child submission should result
    120+        # in them not being evicted
    121+        parent_vsize = 25000
    122+        num_big_parents = 3
    123+        # Need to be large enough to trigger eviction
    124+        # (note that the mempool usage of a tx is about three times its vsize)
    


    rkrux commented at 2:01 pm on October 25, 2024:
    Thanks for adding this comment, helpful!
  20. in test/functional/mempool_limit.py:125 in f32c34d0c3
    120+        # in them not being evicted
    121+        parent_vsize = 25000
    122+        num_big_parents = 3
    123+        # Need to be large enough to trigger eviction
    124+        # (note that the mempool usage of a tx is about three times its vsize)
    125+        assert_greater_than(parent_vsize * num_big_parents * 3, current_info["maxmempool"] - current_info["bytes"])
    


    rkrux commented at 2:03 pm on October 25, 2024:
    IIUC shouldn’t usage be used here instead of bytes because the first argument of assert uses memory usage? https://github.com/bitcoin/bitcoin/blob/master/src/rpc/mempool.cpp#L699-L700

    instagibbs commented at 3:47 pm on October 25, 2024:
    will fix if retouched
  21. in test/functional/mempool_limit.py:156 in f32c34d0c3
    151+
    152+        # Ensure that intra-package trimming is not happening.
    153+        # Each transaction separately satisfies the current
    154+        # minfee and shouldn't need package evaluation to
    155+        # be included. If trimming of a parent were to happen,
    156+        # package evaluation would happen to reintrodce the evicted
    


    rkrux commented at 2:12 pm on October 25, 2024:
    Typo reintrodce

    rkrux commented at 3:02 pm on October 25, 2024:

    “If trimming of a parent were to happen, # package evaluation would happen to reintrodce the evicted parent”

    Out of curiosity: Is the only way for us to know if trimming happened is through debug logs?


    instagibbs commented at 3:47 pm on October 25, 2024:

    Typo reintrodce

    Will fix if I touch again

    There’s no direct way to query that a trimming happened, no. Note that even if it was directly reported, the results can’t really be cached since we’re evicting things.

  22. in test/functional/mempool_limit.py:112 in f32c34d0c3
    107+        mempool_entry_minrate = min(fees_btc_per_kvb)
    108+        mempool_entry_minrate = mempool_entry_minrate.quantize(Decimal("0.00000000"))
    109+
    110+        # There is a gap, our parents will be minrate, with child bringing up descendant fee sufficiently to avoid
    111+        # eviction even though parents cause eviction on their own
    112+        assert_greater_than(mempool_entry_minrate, mempoolmin_feerate)
    


    rkrux commented at 2:42 pm on October 25, 2024:
    For my understanding, can you explain why is there a difference b/w mempool_entry_minrate and mempoolmin_feerate currently as mempool_entry_minrate is calculated based on the current mempool entries that don’t include the to be added parents and child? https://github.com/bitcoin/bitcoin/blob/master/src/rpc/mempool.cpp#L703

    instagibbs commented at 3:47 pm on October 25, 2024:

    A gap can/does happen naturally in that the highest descendant feerate evicted, plus minrelay(1 sat/vbyte) becomes the new floating fee.

    I guess fill_mempool does it in such a way that all the leftover transactions are higher than the new minrelay?

    I’ll take a longer look into seeing if we can guarantee this more directly somehow

  23. rkrux approved
  24. rkrux commented at 3:05 pm on October 25, 2024: none

    tACK f32c34d0c3d4041a301822b27e88d6db4cbf631e

    Successful make and functional tests. In my system, 1 out of the 72 txs in the mempool was evicted when this package of 3 parents and 1 child was submitted.

    Thanks for adding this one, it is a fantastic functional test to have that tests different pieces, I enjoyed going through it. Asked couple questions for my understanding.

  25. DrahtBot requested review from glozow on Oct 25, 2024
  26. DrahtBot requested review from sdaftuar on Oct 25, 2024
  27. sdaftuar commented at 5:07 pm on October 25, 2024: member
    re-ACK f32c34d0c3d4041a301822b27e88d6db4cbf631e
  28. sdaftuar approved
  29. glozow commented at 1:30 pm on October 26, 2024: member
    reACK f32c34d0c3d4041a301822b27e88d6db4cbf631e
  30. glozow merged this on Oct 26, 2024
  31. glozow closed this on Oct 26, 2024


github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2024-12-21 15:12 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me