test: a test to check descendant limits #22582

pull ritickgoenka wants to merge 1 commits into bitcoin:master from ritickgoenka:test_descendant_limit_bushy changing 1 files +70 −0
  1. ritickgoenka commented at 1:20 PM on July 29, 2021: contributor

    This PR adds a new functional test to test the new descendant limits for packages that were proposed in #21800.

    +----------------------+
    |                      |
    |         M1           |
    |        ^  ^          |
    |       M2   ^         |
    |      .      ^        |
    |     .        ^       |
    |    .          ^      |
    |   .            ^     |
    |  M24            ^    |
    |                  ^   |
    |                  P1  |
    |                  ^   |
    |                  P2  |
    |                      |
    +----------------------+
    
                                     

    This test is for checking a transaction to fail its descendant count limits because of a combination of mempool descendants, package direct descendants, and package indirect descendants.

    In this test, P1 has M1 as a mempool ancestor, P2 has no in-mempool ancestors, but when combined P2 has M1 as an ancestor and M1 exceeds descendant_limits (23 in-mempool descendants + 2 in-package descendants, a total of 26 including itself)

  2. fanquake added the label Tests on Jul 29, 2021
  3. DrahtBot commented at 2:03 PM on July 29, 2021: member

    <!--e57a25ab6845829454e8d69fc972939a-->

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

    <!--174a7506f384e20aa4161008e828411d-->

    Conflicts

    No conflicts as of last run.

  4. ritickgoenka force-pushed on Jul 29, 2021
  5. tryphe commented at 1:43 AM on July 30, 2021: contributor

    Concept ACK

  6. fanquake requested review from glozow on Jul 30, 2021
  7. in test/functional/rpc_packages.py:325 in c18188e962 outdated
     320 | +                    P2   P3
     321 | +
     322 | +        P1 has M1a as a mempool ancestor, P2 has only M1b as in-mempool ancestor whereas P3 has
     323 | +        no in-mempool ancestors, but when combined both P2 and P3 have M1a as an ancestor and
     324 | +        M1a exceeds descendant_limits (23 in-mempool descendants + 3 in-package descendants)
     325 | +        """
    


    glozow commented at 6:52 AM on July 30, 2021:

    What does M1b do? I don't see how it's relevant to the test :thinking:


    ritickgoenka commented at 1:34 PM on July 30, 2021:

    To test a transaction having a direct connection to mempool doesn't affect it being counted as an indirect descendant of some transaction in the mempool. If this doesn't make much sense I can remove M1b.


    glozow commented at 1:53 PM on August 11, 2021:

    ^ This description or a short summary of it would be good in place of the "bushy" comment


    glozow commented at 2:25 PM on August 11, 2021:

    Right now the test doesn't utilize M1b at all - it should test that the package [P1, P2] passes but [P1, P2, P3] fails.


    jnewbery commented at 2:25 PM on August 11, 2021:

    This test would fail regardless of whether M1b exists or not (since M1a has 23 descendants in the mempool and 3 descendants in the package). It doesn't seem to me to be testing an edgecase that isn't already covered by the other tests in rpc_packages.py.

  8. in test/functional/rpc_packages.py:308 in c18188e962 outdated
     304 | @@ -304,6 +305,109 @@ def test_descendant_limits(self):
     305 |          assert all([res["allowed"] for res in node.testmempoolaccept(rawtxs=package_hex)])
     306 |          node.generate(1)
     307 |  
     308 | +    def test_descendant_limits_bushy(self):
    


    glozow commented at 6:56 AM on July 30, 2021:

    I wouldn't call this bushy, it's kind of giraffe-shaped? maybe test_descendant_limits_2 or test_descendant_limits_mempool_dominated


    ritickgoenka commented at 1:17 PM on July 30, 2021:

    Done

  9. glozow commented at 7:01 AM on July 30, 2021: member

    Concept ACK to more testing.

    The commit message for c18188e96204f9264e2ed64ab5e53f3abdd137e5 seems to contain some squash comments? Would be better to describe exactly what edge case you're testing / coverage you're adding.

  10. ritickgoenka force-pushed on Jul 30, 2021
  11. ritickgoenka marked this as ready for review on Jul 30, 2021
  12. DrahtBot added the label Needs rebase on Aug 9, 2021
  13. glozow commented at 6:18 AM on August 9, 2021: member

    Will review again after rebase - note that the mempool tests have been moved to mempool_package_limits.py

  14. ritickgoenka force-pushed on Aug 10, 2021
  15. DrahtBot removed the label Needs rebase on Aug 10, 2021
  16. ritickgoenka marked this as a draft on Aug 10, 2021
  17. ritickgoenka force-pushed on Aug 10, 2021
  18. ritickgoenka marked this as ready for review on Aug 11, 2021
  19. in test/functional/mempool_package_limits.py:206 in 2bc8b5a2c5 outdated
     201 | +        parents_tx = []
     202 | +        values = []
     203 | +        scripts = []
     204 | +        # M1a
     205 | +        first_coin_a = self.coins.pop()
     206 | +        parent_value = (first_coin_a["amount"] - Decimal("0.0002")) / 2 # Deduct reasonable fee and make 2 outputs
    


    glozow commented at 1:21 PM on August 11, 2021:

    I actually think a fee of just Decimal("0.0001") would be sufficient here. In fact, I think it'd be best to import DEFAULT_FEE from test_framework/wallet.py and use that throughout this test.

  20. in test/functional/mempool_package_limits.py:193 in 2bc8b5a2c5 outdated
     188 | +               ^         ^           ^
     189 | +                ^       ^            M23a
     190 | +                 ^     ^
     191 | +                  ^   P1
     192 | +                   ^ ^  ^
     193 | +                    P2   P3
    


    glozow commented at 1:33 PM on August 11, 2021:

    nit: this test would be simplified if you made M2a .... M23a be a chain spending vout[0] of M1a. It'd save maybe 5-10 lines.

  21. in test/functional/mempool_package_limits.py:182 in 2bc8b5a2c5 outdated
     177 | @@ -177,6 +178,107 @@ def test_desc_count_limits(self):
     178 |          node.generate(1)
     179 |          assert all([res["allowed"] for res in node.testmempoolaccept(rawtxs=package_hex)])
     180 |  
     181 | +    def test_desc_count_limits_2(self):
     182 | +        """Create A bushy Package with 24 transaction in mempool and 3 transaction in package
    


    glozow commented at 1:50 PM on August 11, 2021:

    Again, not bushy

  22. glozow commented at 1:52 PM on August 11, 2021: member

    Thanks for rebasing, the test is well-written and does what the comment says it does.

    Suggestion: label your commit message with [test] and add a short description about why this test is an improvement.

  23. glozow commented at 1:54 PM on August 11, 2021: member

    Another suggestion (probably for a different PR): This doesn't matter that much, but we have quite a few of the same lines repeated in this test. Given how many OP_TRUE spends there are, I think it'd be good to either add a OP_TRUE variation of make_chain to wallet.py or, better yet, make all those functions methods of MiniWallet.

  24. ritickgoenka requested review from glozow on Aug 11, 2021
  25. ritickgoenka force-pushed on Aug 11, 2021
  26. in test/functional/mempool_package_limits.py:241 in 4fd79792dd outdated
     265 | +        child_hex = create_child_with_parents(node, self.address, self.privkeys, parents_tx, values, scripts)
     266 | +        package_hex.append(child_hex)
     267 | +
     268 | +        assert_equal(24, node.getmempoolinfo()["size"])
     269 | +        assert_equal(3, len(package_hex))
     270 | +        testres = node.testmempoolaccept(rawtxs=package_hex)
    


    glozow commented at 9:28 AM on August 12, 2021:

    Did you consider the suggestion about asserting success for [P1, P3] but failure for [P1, P2, P3] ?


    ritickgoenka commented at 6:17 PM on August 12, 2021:

    I have removed M1b as it was creating more confusion and as jnewbery pointed out the test would still fail regardless of M1b being present there and it was not adding any edgecase that it not already present.

  27. in test/functional/mempool_package_limits.py:198 in 4fd79792dd outdated
     193 | +                               P1
     194 | +                              ^  ^
     195 | +                             P2   P3
     196 | +        P1 has M1a as a mempool ancestor, P2 has only M1b as in-mempool ancestor whereas P3 has
     197 | +        no in-mempool ancestors, but when combined both P2 and P3 have M1a as an ancestor and
     198 | +        M1a exceeds descendant_limits (23 in-mempool descendants + 3 in-package descendants)
    


    glozow commented at 9:29 AM on August 12, 2021:

    This comment/diagram is now incorrect - M1b is the parent of P2, not P1

  28. ritickgoenka force-pushed on Aug 12, 2021
  29. ritickgoenka force-pushed on Aug 12, 2021
  30. in test/functional/mempool_package_limits.py:197 in 5a7050c63c outdated
     192 | +                              P1
     193 | +                             ^  ^
     194 | +                            P2   P3
     195 | +        P1 has M1a as a mempool ancestor, P2 and P3 have no in-mempool ancestors, but when
     196 | +        combined both P2 and P3 have M1a as an ancestor and M1a exceeds descendant_limits
     197 | +        (23 in-mempool descendants + 3 in-package descendants)
    


    glozow commented at 10:55 AM on August 16, 2021:
            (22 in-mempool descendants + 3 in-package descendants, a total of 26 including itself).
    
  31. glozow commented at 10:57 AM on August 16, 2021: member

    utACK 5a7050c63c1a574abf336a47b18e154554a4020a

  32. glozow commented at 12:11 PM on August 16, 2021: member

    PR description needs to be updated

  33. jnewbery commented at 1:33 PM on August 16, 2021: member

    I still don't understand what logic this is testing that isn't already covered by the test_desc_count_limits() subtest.

  34. ritickgoenka commented at 5:11 PM on August 16, 2021: contributor

    I still don't understand what logic this is testing that isn't already covered by the test_desc_count_limits() subtest.

    It is testing if the second generation in Package transactions are considered while checking Descendant count limits. It is analogous to the 'test_anc_count_limits_2()' subtest for Ancestor count limits.

  35. ritickgoenka force-pushed on Aug 17, 2021
  36. jnewbery commented at 3:56 PM on August 17, 2021: member

    @glozow has pointed out that this scenario is for a transaction to fail its descendant limit count due to a combination of mempool descendants, package direct descendants, and package indirect descendants, which seems like a reasonable thing to test.

    I think the transaction P3 is unnecessary, since the package would fail with just P2. It's good for a test to fail at the edge case (i.e. the package would be accepted if you removed just one transaction).

    I'd also recommend you remove the image from the PR description and replace it with an ascii drawing. The PR description is included in the merge commit, so it's best if it's plain text without attachments.

  37. ritickgoenka force-pushed on Aug 19, 2021
  38. ritickgoenka force-pushed on Aug 19, 2021
  39. in test/functional/mempool_package_limits.py:243 in 2ef27b5b78 outdated
     237 | +        package_hex.append(tx_child_p2_hex)
     238 | +
     239 | +        assert_equal(24, node.getmempoolinfo()["size"])
     240 | +        assert_equal(2, len(package_hex))
     241 | +        testres = node.testmempoolaccept(rawtxs=package_hex)
     242 | +        for txres in testres:
    


    ryanofsky commented at 5:33 PM on August 19, 2021:

    In commit "[test] checks descendants limtis for second generation Package descendants" (e0f92f30954438540e6a676af77d17fbb963ca5d)

    May be paranoid, but could be good to check assert_equal(len(testres), len(package_hex))

  40. ryanofsky commented at 5:36 PM on August 19, 2021: member

    Code review ACK e0f92f30954438540e6a676af77d17fbb963ca5d. Seems like a useful and straightforward test case, assuming it doesn't duplicate existing coverage.

  41. [test] checks descendants limtis for second generation Package descendants fa7db1cbf7
  42. ritickgoenka force-pushed on Aug 26, 2021
  43. ritickgoenka requested review from jnewbery on Sep 5, 2021
  44. ryanofsky approved
  45. ryanofsky commented at 6:16 PM on September 7, 2021: member

    Code review ACK fa7db1cbf7e8400b625fccd5757f8e1b200796bd. Only were suggested changes since last review: simplifying test and dropping P3 transaction as John suggested, and adding assert_equal I suggested

  46. fanquake requested review from glozow on Sep 8, 2021
  47. glozow commented at 9:54 AM on September 9, 2021: member

    ACK fa7db1cbf7e8400b625fccd5757f8e1b200796bd

  48. in test/functional/mempool_package_limits.py:220 in fa7db1cbf7
     215 | +        # Chain M2...M24
     216 | +        spk = parent_tx.vout[0].scriptPubKey.hex()
     217 | +        value = parent_value
     218 | +        txid = parent_txid
     219 | +        for i in range(23): # M2...M24
     220 | +            (tx, txhex, value, spk) = make_chain(node, self.address, self.privkeys, txid, value, 0, spk)
    


    jnewbery commented at 1:27 PM on September 9, 2021:
                tx, txhex, value, spk = make_chain(node, self.address, self.privkeys, txid, value, 0, spk)
    
  49. in test/functional/mempool_package_limits.py:206 in fa7db1cbf7
     201 | +        package_hex = []
     202 | +        # M1
     203 | +        first_coin_a = self.coins.pop()
     204 | +        parent_value = (first_coin_a["amount"] - DEFAULT_FEE) / 2 # Deduct reasonable fee and make 2 outputs
     205 | +        inputs = [{"txid": first_coin_a["txid"], "vout": 0}]
     206 | +        outputs = [{self.address : parent_value}, {ADDRESS_BCRT1_P2WSH_OP_TRUE : parent_value}]
    


    jnewbery commented at 1:34 PM on September 9, 2021:

    Consider using a linter like flake8 or a formatter like black to catch/fix PEP8 violations:

            outputs = [{self.address: parent_value}, {ADDRESS_BCRT1_P2WSH_OP_TRUE: parent_value}]
    
  50. jnewbery commented at 1:35 PM on September 9, 2021: member

    ACK fa7db1cbf7

    I've left a couple of comments inline, but they can be picked up in #22901.

    If you have to touch this again, I'd suggest changing the commit log:

    -[test] checks descendants limtis for second generation Package descendants
    +[test] check descendant limits for second generation package descendants
    
  51. MarcoFalke merged this on Sep 9, 2021
  52. MarcoFalke closed this on Sep 9, 2021

  53. sidhujag referenced this in commit 59d084d3f5 on Sep 11, 2021
  54. Fabcien referenced this in commit f61f449edd on Oct 25, 2022
  55. DrahtBot locked this on Oct 30, 2022

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: 2026-05-02 03:14 UTC

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