test: Assert that when we add the max orphan amount that we cannot add anymore and that a random orphan gets dropped #31040

pull kevkevinpal wants to merge 1 commits into bitcoin:master from kevkevinpal:maxOrphanTest changing 2 files +45 −1
  1. kevkevinpal commented at 2:31 pm on October 6, 2024: contributor

    After joining the bitcoin pr review club about #30793

    I learned about CVE-2012-3789

    So I was motivated to write a functional test that covers this part of the code,

    This test should add the max number of orphans to a nodes orphanage and then attempt to add another, then asserts that the number of orphans is still at the max amount

  2. DrahtBot commented at 2:31 pm on October 6, 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, instagibbs, tdb3, achow101
    Concept ACK Prabhat1308
    Stale ACK Christewart

    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:

    • #31043 (rpc: getorphantxs follow-up by tdb3)

    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. DrahtBot added the label Tests on Oct 6, 2024
  4. tdb3 commented at 4:17 pm on October 6, 2024: contributor

    Concept ACK Thanks, this is useful! I’m uncertain if this check is better suited for p2p_orphan_handling or rpc_getorphantxs (or for a feature_orphanage or mempool_orphanage). If p2p_orphan_handling is the preferred location, I’m happy to include your commit (preserving you as author) in #31037.

    https://github.com/bitcoin/bitcoin/blob/master/test/functional/README.md#naming-guidelines

    Can also check unit tests (https://github.com/bitcoin/bitcoin/blob/master/src/test/orphanage_tests.cpp)

  5. in test/functional/rpc_getorphantxs.py:152 in 3cab9b5808 outdated
    147+        self.log.info("Check that we do not add more than the max orphan amount and that the first orphan has been dropped")
    148+        tx_parent_1 = self.wallet.create_self_transfer()
    149+        tx_child_1 = self.wallet.create_self_transfer(utxo_to_spend=tx_parent_1["new_utxo"])
    150+        peer_1.send_and_ping(msg_tx(tx_child_1["tx"]))
    151+        orphanage = node.getorphantxs(verbosity=2)
    152+        assert tx_in_orphanage(node, tx_child_1["tx"])
    


    theStack commented at 0:55 am on October 7, 2024:
    I think this line makes the test flaky, as the orphan tx to drop in TxOrphanage::LimitOrphans is chosen randomly, i.e. it could also be the last one added (tx_child_1 in this case). Didn’t test locally yet, but I’d assume that about every 100th test run fails.

    kevkevinpal commented at 1:38 pm on October 7, 2024:
    Good catch! Just to make sure I ran it 100 times and on the 90th attempt it failed, I removed the assert in 33e4dc8
  6. kevkevinpal commented at 1:07 pm on October 7, 2024: contributor

    Concept ACK Thanks, this is useful! I’m uncertain if this check is better suited for p2p_orphan_handling or rpc_getorphantxs (or for a feature_orphanage or mempool_orphanage). If p2p_orphan_handling is the preferred location, I’m happy to include your commit (preserving you as author) in #31037.

    https://github.com/bitcoin/bitcoin/blob/master/test/functional/README.md#naming-guidelines

    Can also check unit tests (https://github.com/bitcoin/bitcoin/blob/master/src/test/orphanage_tests.cpp)

    yes if you would like to pick this commit that would be great then I can close this PR

  7. kevkevinpal force-pushed on Oct 7, 2024
  8. in test/functional/rpc_getorphantxs.py:142 in 33e4dc834f outdated
    137+        for i in range(MAX_ORPHANS):
    138+            tx_parent_1 = self.wallet.create_self_transfer()
    139+            tx_child_1 = self.wallet.create_self_transfer(utxo_to_spend=tx_parent_1["new_utxo"])
    140+            peer_1.send_and_ping(msg_tx(tx_child_1["tx"]))
    141+
    142+            orphanage = node.getorphantxs(verbosity=2)
    


    danielabrozzoni commented at 2:23 pm on October 11, 2024:
    This line shouldn’t be necessary, you’re not using the resulting orphanage anywhere

    kevkevinpal commented at 9:51 pm on October 11, 2024:
    agreed! Updated in 4d59b9a
  9. in test/functional/rpc_getorphantxs.py:144 in 33e4dc834f outdated
    139+            tx_child_1 = self.wallet.create_self_transfer(utxo_to_spend=tx_parent_1["new_utxo"])
    140+            peer_1.send_and_ping(msg_tx(tx_child_1["tx"]))
    141+
    142+            orphanage = node.getorphantxs(verbosity=2)
    143+            assert tx_in_orphanage(node, tx_child_1["tx"])
    144+        orphanage = node.getorphantxs(verbosity=2)
    


    danielabrozzoni commented at 2:23 pm on October 11, 2024:
    nit: I don’t think verbosity=2 is needed

    kevkevinpal commented at 9:50 pm on October 11, 2024:
    Thank you! updated in 4d59b9a
  10. in test/functional/rpc_getorphantxs.py:151 in 33e4dc834f outdated
    146+
    147+        self.log.info("Check that we do not add more than the max orphan amount and that the first orphan has been dropped")
    148+        tx_parent_1 = self.wallet.create_self_transfer()
    149+        tx_child_1 = self.wallet.create_self_transfer(utxo_to_spend=tx_parent_1["new_utxo"])
    150+        peer_1.send_and_ping(msg_tx(tx_child_1["tx"]))
    151+        orphanage = node.getorphantxs(verbosity=2)
    


    danielabrozzoni commented at 2:24 pm on October 11, 2024:
    nit: same as above, verbosity shouldn’t be needed

    kevkevinpal commented at 9:50 pm on October 11, 2024:
    Thanks! updated in 4d59b9a
  11. in test/functional/rpc_getorphantxs.py:140 in 33e4dc834f outdated
    135+
    136+        self.log.info("Filling up orphanage with " + str(MAX_ORPHANS) + "(MAX_ORPHANS) orphans")
    137+        for i in range(MAX_ORPHANS):
    138+            tx_parent_1 = self.wallet.create_self_transfer()
    139+            tx_child_1 = self.wallet.create_self_transfer(utxo_to_spend=tx_parent_1["new_utxo"])
    140+            peer_1.send_and_ping(msg_tx(tx_child_1["tx"]))
    


    danielabrozzoni commented at 2:39 pm on October 11, 2024:

    The test is currently a bit slow, and I think it might be because you’re using send_and_ping, which waits for the other peer to send back a pong in each iteration of the loop.

    You could send the messages in the for loop and then ping only at the end:

    0        for i in range(MAX_ORPHANS):
    1            tx_parent_1 = self.wallet.create_self_transfer()
    2            tx_child_1 = self.wallet.create_self_transfer(utxo_to_spend=tx_parent_1["new_utxo"])
    3            peer_1.send_message(msg_tx(tx_child_1["tx"]))
    4
    5        peer_1.sync_with_ping()
    6
    7        orphanage = node.getorphantxs()
    8        assert_equal(len(orphanage), MAX_ORPHANS)
    

    The drawback would be that you’re not checking that every single tx is entering the orphanage, although you could do that simply by saving the orphans and checking after the ping:

     0        orphans = []
     1        for i in range(MAX_ORPHANS):
     2            tx_parent_1 = self.wallet.create_self_transfer()
     3            tx_child_1 = self.wallet.create_self_transfer(utxo_to_spend=tx_parent_1["new_utxo"])
     4            orphans.append(tx_child_1["tx"])
     5            peer_1.send_message(msg_tx(tx_child_1["tx"]))
     6
     7        peer_1.sync_with_ping()
     8
     9        orphanage = node.getorphantxs()
    10        assert_equal(len(orphanage), MAX_ORPHANS)
    11
    12        for orphan in orphans:
    13            assert tx_in_orphanage(node, orphan)
    

    Personally I think the first option is good enough though, what do you think?


    kevkevinpal commented at 9:50 pm on October 11, 2024:

    Thank you for the review! I’ve updated in 4d59b9a

    the second one looked good to me! I prefer asserting that each individual tx made it into the orphanage

  12. instagibbs commented at 6:05 pm on October 11, 2024: member
    concept ACK on a functional test for this logic, note that at the unit test level there is already a bit of coverage: https://github.com/bitcoin/bitcoin/blob/master/src/test/orphanage_tests.cpp#L106
  13. kevkevinpal force-pushed on Oct 11, 2024
  14. in test/functional/rpc_getorphantxs.py:138 in 4d59b9a517 outdated
    133+
    134+        peer_1 = node.add_p2p_connection(P2PInterface())
    135+
    136+        self.log.info("Filling up orphanage with " + str(MAX_ORPHANS) + "(MAX_ORPHANS) orphans")
    137+        orphans = []
    138+        for i in range(MAX_ORPHANS):
    


    brunoerg commented at 9:58 am on October 16, 2024:

    nit

    0        for _ in range(MAX_ORPHANS):
    

    kevkevinpal commented at 12:52 pm on October 16, 2024:
    thanks! Updated in 60dbd42
  15. in test/functional/rpc_getorphantxs.py:151 in 4d59b9a517 outdated
    146+        assert_equal(len(orphanage), MAX_ORPHANS)
    147+
    148+        for orphan in orphans:
    149+            assert tx_in_orphanage(node, orphan)
    150+
    151+        self.log.info("Check that we do not add more than the max orphan amount and that the first orphan has been dropped")
    


    brunoerg commented at 10:03 am on October 16, 2024:
    The comment here says that the first orphan has been dropped and the PR title says “a random orphan gets dropped”. I don’t know so much about it, what is the expected behavior?

    kevkevinpal commented at 12:54 pm on October 16, 2024:

    Thanks! I updated in 60dbd42

    Its supposed to be a random orphan but I removed “and that the first orphan has been dropped” since we are not checking if a random orphan has been dropped and just checking the max orphan amount

  16. kevkevinpal force-pushed on Oct 16, 2024
  17. Christewart commented at 8:17 pm on October 18, 2024: contributor

    I’m a bit confused to the behavior i’m observing on this PR. Not necessarily anything to do with the test, but how orphans are handled.

    I tried adding another part to the test case to check we can clear the orphanage by propagating parent transactions: https://github.com/Christewart/bitcoin/commit/04815c463d331f674f67fdcb3b8da601484d7a33

    It appears that to totally clear the orphanage, we need to propagate the parent transaction for the last child transaction (the orphan we rejected because we surpassed MAX_ORPHANS), which is unexpected I believe?

  18. Prabhat1308 commented at 9:36 pm on October 18, 2024: none
    Concept ACK for the test While we are trying to add another orphan transaction when the max amount is reached , why are we dropping a random orphan and not just the incoming orphan ? Even in the condition of the node getting DOSed , having to remove a random transaction translates to some amount of work done while its not the case when we just drop the incoming transaction.
  19. Christewart commented at 3:45 pm on October 21, 2024: contributor

    I’m a bit confused to the behavior i’m observing on this PR. Not necessarily anything to do with the test, but how orphans are handled.

    I tried adding another part to the test case to check we can clear the orphanage by propagating parent transactions: Christewart@04815c4

    It appears that to totally clear the orphanage, we need to propagate the parent transaction for the last child transaction (the orphan we rejected because we surpassed MAX_ORPHANS), which is unexpected I believe?

    ok figured this out, it appears we have 1 orphan in the mempool when the unit test begins. I’ve modified the code to account for this: https://github.com/Christewart/bitcoin/commit/712206ead880472fcc64c330bee602f29c03f1cb

  20. kevkevinpal force-pushed on Oct 22, 2024
  21. kevkevinpal commented at 1:48 am on October 22, 2024: contributor

    I’m a bit confused to the behavior i’m observing on this PR. Not necessarily anything to do with the test, but how orphans are handled. I tried adding another part to the test case to check we can clear the orphanage by propagating parent transactions: Christewart@04815c4 It appears that to totally clear the orphanage, we need to propagate the parent transaction for the last child transaction (the orphan we rejected because we surpassed MAX_ORPHANS), which is unexpected I believe?

    ok figured this out, it appears we have 1 orphan in the mempool when the unit test begins. I’ve modified the code to account for this: Christewart@712206e

    Thank you for the review!

    I updated the PR in bf46723

    I restarted the node with -persistmempool=0 so we drop that initial orphan in the mempool and then also I added the additional code you added for clearing the orphanage since that seemed like useful cleanup in the test

  22. kevkevinpal commented at 1:54 am on October 22, 2024: contributor

    Concept ACK for the test While we are trying to add another orphan transaction when the max amount is reached , why are we dropping a random orphan and not just the incoming orphan ? Even in the condition of the node getting DOSed , having to remove a random transaction translates to some amount of work done while its not the case when we just drop the incoming transaction.

    If we drop the incoming orphan then an attacker can quickly fill up a node’s orphan pool with tx’s that will never get a valid parent and then effectively block honest child transactions which are awaiting their parent

  23. Christewart commented at 12:11 pm on October 22, 2024: contributor
    ACK bf46723537c37cb1ee7f84ffe7b75c253beadb89
  24. DrahtBot requested review from instagibbs on Oct 22, 2024
  25. DrahtBot requested review from tdb3 on Oct 22, 2024
  26. Ironlung23 approved
  27. Ironlung23 approved
  28. in test/functional/test_framework/mempool_util.py:22 in bf46723537 outdated
    18@@ -19,6 +19,7 @@
    19     MiniWallet,
    20 )
    21 
    22+MAX_ORPHANS = 100
    


    rkrux commented at 6:31 am on October 23, 2024:
    Let’s keep the same name in the functional test for uniformity and easy reference? https://github.com/bitcoin/bitcoin/blob/master/src/net_processing.h#L27

    kevkevinpal commented at 12:21 pm on October 23, 2024:
    Sounds good to me! Updated in 6741cde
  29. rkrux approved
  30. rkrux commented at 6:32 am on October 23, 2024: none

    tACK bf46723537c37cb1ee7f84ffe7b75c253beadb89

    Successful make and functional tests.

  31. kevkevinpal force-pushed on Oct 23, 2024
  32. kevkevinpal force-pushed on Oct 23, 2024
  33. DrahtBot commented at 1:48 pm on October 23, 2024: contributor

    🚧 At least one of the CI tasks failed. Debug: https://github.com/bitcoin/bitcoin/runs/31946723457

    Try to run the tests locally, according to the documentation. However, a CI failure may still happen due to a number of reasons, for example:

    • Possibly due to a silent merge conflict (the changes in this pull request being incompatible with the current code in the target branch). If so, make sure to rebase on the latest commit of the target branch.

    • A sanitizer issue, which can only be found by compiling with the sanitizer and running the affected test.

    • An intermittent issue.

    Leave a comment here, if you need help tracking down a confusing failure.

  34. DrahtBot added the label CI failed on Oct 23, 2024
  35. maflcko commented at 1:55 pm on October 23, 2024: member
  36. in test/functional/rpc_getorphantxs.py:131 in 6741cde5fe outdated
    126@@ -125,6 +127,48 @@ def orphan_details_match(self, orphan, tx, verbosity):
    127             self.log.info("Check the transaction hex of orphan")
    128             assert_equal(orphan["hex"], tx["hex"])
    129 
    130+    def test_max_orphan_amount(self):
    131+        self.log.info("Check that once we reach the max orphan amount we dont get any new orphans")
    


    instagibbs commented at 1:57 pm on October 23, 2024:

    We accept new orphans, we just never exceed limits

    0        self.log.info("Check that we never exceed our storage limits for orphans")
    

    kevkevinpal commented at 11:27 pm on October 24, 2024:
    updated in f2b920c
  37. DrahtBot removed the label CI failed on Oct 23, 2024
  38. in test/functional/rpc_getorphantxs.py:135 in 6741cde5fe outdated
    126@@ -125,6 +127,48 @@ def orphan_details_match(self, orphan, tx, verbosity):
    127             self.log.info("Check the transaction hex of orphan")
    128             assert_equal(orphan["hex"], tx["hex"])
    129 
    130+    def test_max_orphan_amount(self):
    131+        self.log.info("Check that once we reach the max orphan amount we dont get any new orphans")
    132+
    133+        MAX_ORPHANS = 100
    134+
    135+        self.restart_node(0, extra_args=["-persistmempool=0"])
    


    instagibbs commented at 1:58 pm on October 23, 2024:
    unsure nit: Might be faster to mine blocks until mempool is empty?

    kevkevinpal commented at 11:25 pm on October 24, 2024:
    This is now removed after moving to p2p_orphan_handling.py in 3bc3bcc
  39. in test/functional/rpc_getorphantxs.py:146 in 6741cde5fe outdated
    141+        self.wait_until(lambda: len(node.getorphantxs()) == 0)
    142+
    143+        self.log.info("Filling up orphanage with " + str(MAX_ORPHANS) + "(MAX_ORPHANS) orphans")
    144+        orphans = []
    145+        parent_orphans = []
    146+        for _ in range(MAX_ORPHANS):
    


    instagibbs commented at 2:00 pm on October 23, 2024:
    before filling up the orphanage, do we want to mock time to make it static for the duration of this test? We don’t want things to be evicted even if somehow the test is slow.

    kevkevinpal commented at 11:25 pm on October 24, 2024:
    I think the @cleanup function when moving the test to p2p_orphan_handling.py in 3bc3bcc should be handling this now
  40. in test/functional/rpc_getorphantxs.py:23 in 6741cde5fe outdated
    19@@ -20,6 +20,8 @@ def run_test(self):
    20         self.wallet = MiniWallet(self.nodes[0])
    21         self.test_orphan_activity()
    22         self.test_orphan_details()
    23+        self.generate(self.wallet, 160)
    


    instagibbs commented at 2:03 pm on October 23, 2024:
    if MAX_ORPHANS is defined it can be used here directly

    kevkevinpal commented at 11:26 pm on October 24, 2024:
    I’ve just defined it at the top of the test file should that be fine?
  41. instagibbs approved
  42. instagibbs commented at 2:05 pm on October 23, 2024: member

    ACK 6741cde5fe3575cc0b58a52c4a30058fa08c4beb

    non blocking nits only

  43. DrahtBot requested review from rkrux on Oct 23, 2024
  44. DrahtBot requested review from Christewart on Oct 23, 2024
  45. tdb3 commented at 4:31 pm on October 23, 2024: contributor

    Concept ACK Thanks, this is useful! I’m uncertain if this check is better suited for p2p_orphan_handling or rpc_getorphantxs (or for a feature_orphanage or mempool_orphanage). If p2p_orphan_handling is the preferred location, I’m happy to include your commit (preserving you as author) in #31037. https://github.com/bitcoin/bitcoin/blob/master/test/functional/README.md#naming-guidelines Can also check unit tests (https://github.com/bitcoin/bitcoin/blob/master/src/test/orphanage_tests.cpp)

    yes if you would like to pick this commit that would be great then I can close this PR

    Sorry I’ve been out of pocket lately (travel and illness). There’s been a lot of great review on this PR, so I don’t want to derail it. The thought is that rpc_getorphanstxs would be scoped to testing the functionality of the getorphantxs RPC itself (i.e. does it return accurate/correct info, etc.) and that orphanage functionality (e.g. what happens when we reach capacity) would go where other orphanage-related functionality tests live (e.g. p2p_orphan_handling). Thoughts @instagibbs? This isn’t a hill I’m willing to die on, but I’m thinking it would make this a bit more organized.

    I’m planning to make changes to p2p_orphan_handling in #31037, but it might be a few days before I get to it and I don’t want to hold this PR hostage, so I can always rebase on top of this one if merged.

  46. instagibbs commented at 4:34 pm on October 23, 2024: member
    @tdb3 reasonable suggestion, shouldn’t take much effort?
  47. tdb3 commented at 4:36 pm on October 23, 2024: contributor

    @tdb3 reasonable suggestion, shouldn’t take much effort?

    Yeah, I think it would just be moving the logic over to p2p_orphan_handling.

  48. kevkevinpal force-pushed on Oct 24, 2024
  49. kevkevinpal commented at 11:23 pm on October 24, 2024: contributor

    Concept ACK Thanks, this is useful! I’m uncertain if this check is better suited for p2p_orphan_handling or rpc_getorphantxs (or for a feature_orphanage or mempool_orphanage). If p2p_orphan_handling is the preferred location, I’m happy to include your commit (preserving you as author) in #31037. https://github.com/bitcoin/bitcoin/blob/master/test/functional/README.md#naming-guidelines Can also check unit tests (https://github.com/bitcoin/bitcoin/blob/master/src/test/orphanage_tests.cpp)

    yes if you would like to pick this commit that would be great then I can close this PR

    Sorry I’ve been out of pocket lately (travel and illness). There’s been a lot of great review on this PR, so I don’t want to derail it. The thought is that rpc_getorphanstxs would be scoped to testing the functionality of the getorphantxs RPC itself (i.e. does it return accurate/correct info, etc.) and that orphanage functionality (e.g. what happens when we reach capacity) would go where other orphanage-related functionality tests live (e.g. p2p_orphan_handling). Thoughts @instagibbs? This isn’t a hill I’m willing to die on, but I’m thinking it would make this a bit more organized.

    I’m planning to make changes to p2p_orphan_handling in #31037, but it might be a few days before I get to it and I don’t want to hold this PR hostage, so I can always rebase on top of this one if merged.

    Hope you are feeling better @tdb3

    I’ve moved the new test to p2p_orphan_handling.py in 3bc3bcc

    let me know if you have any other suggestions!

  50. kevkevinpal force-pushed on Oct 24, 2024
  51. in test/functional/p2p_orphan_handling.py:45 in f2b920c31c outdated
    41@@ -41,6 +42,8 @@
    42 # for one peer and y seconds for another, use specific values instead.
    43 TXREQUEST_TIME_SKIP = NONPREF_PEER_TX_DELAY + TXID_RELAY_DELAY + OVERLOADED_PEER_TX_DELAY + 1
    44 
    45+MAX_ORPHANS = 100
    


    tdb3 commented at 0:42 am on October 25, 2024:
    nit: Could put it in test/functional/test_framework/mempool_util.py as DEFAULT_MAX_ORPHAN_TRANSACTIONS to match https://github.com/bitcoin/bitcoin/blob/947f2925d55f363cf1880315d467fc2edac04545/src/net_processing.h#L27

    kevkevinpal commented at 1:49 am on October 25, 2024:
    Thanks! Updated in 5c299ec
  52. in test/functional/p2p_orphan_handling.py:576 in f2b920c31c outdated
    568@@ -566,6 +569,47 @@ def test_orphan_txid_inv(self):
    569         assert tx_child["txid"] in node_mempool
    570         assert_equal(node.getmempoolentry(tx_child["txid"])["wtxid"], tx_child["wtxid"])
    571 
    572+    @cleanup
    573+    def test_max_orphan_amount(self):
    574+        self.log.info("Check that we never exceed our storage limits for orphans")
    575+
    576+        self.generate(self.wallet, 160)
    


    tdb3 commented at 0:48 am on October 25, 2024:

    Generating 160 blocks might be overkill. The following generates one and moves node = self.nodes[0] to just under the opening log (to match other functions).

     0diff --git a/test/functional/p2p_orphan_handling.py b/test/functional/p2p_orphan_handling.py
     1index 0a88b4c9587..5276814a087 100755
     2--- a/test/functional/p2p_orphan_handling.py
     3+++ b/test/functional/p2p_orphan_handling.py
     4@@ -572,9 +572,9 @@ class OrphanHandlingTest(BitcoinTestFramework): [@cleanup](/bitcoin-bitcoin/contributor/cleanup/)
     5     def test_max_orphan_amount(self):
     6         self.log.info("Check that we never exceed our storage limits for orphans")
     7-
     8-        self.generate(self.wallet, 160)
     9         node = self.nodes[0]
    10+
    11+        self.generate(self.wallet, 1)
    12         peer_1 = node.add_p2p_connection(P2PInterface())
    13 
    14         self.log.info("Check that orphanage is empty on start of test")
    

    kevkevinpal commented at 1:49 am on October 25, 2024:
    Thanks! Updated in 5c299ec
  53. tdb3 approved
  54. tdb3 commented at 0:49 am on October 25, 2024: contributor
    ACK f2b920c31cc1254c510dcb9cdc14b73d50f800a2 Thanks for moving the test to p2p_orphan_handling! Left some non-blocking recommendations.
  55. DrahtBot requested review from instagibbs on Oct 25, 2024
  56. in test/functional/p2p_orphan_handling.py:581 in f2b920c31c outdated
    576+        self.generate(self.wallet, 160)
    577+        node = self.nodes[0]
    578+        peer_1 = node.add_p2p_connection(P2PInterface())
    579+
    580+        self.log.info("Check that orphanage is empty on start of test")
    581+        self.wait_until(lambda: len(node.getorphantxs()) == 0)
    


    glozow commented at 1:28 am on October 25, 2024:
    nit: why is this a wait_until instead of an assert?

    kevkevinpal commented at 1:49 am on October 25, 2024:
    Thanks! Updated in 5c299ec
  57. test: Assert that when we add the max orphan amount that we cannot add anymore and that a random orphan gets dropped 5c299ecafe
  58. kevkevinpal force-pushed on Oct 25, 2024
  59. in test/functional/p2p_orphan_handling.py:45 in 5c299ecafe
    41@@ -41,6 +42,8 @@
    42 # for one peer and y seconds for another, use specific values instead.
    43 TXREQUEST_TIME_SKIP = NONPREF_PEER_TX_DELAY + TXID_RELAY_DELAY + OVERLOADED_PEER_TX_DELAY + 1
    44 
    45+DEFAULT_MAX_ORPHAN_TRANSACTIONS = 100
    


    rkrux commented at 9:26 am on October 25, 2024:
    Was this #31040 (review) done in 5c299ecafe6f336cffa145d28036b04b87e26712? I could not find it.
  60. in test/functional/p2p_orphan_handling.py:606 in 5c299ecafe
    601+        tx_parent_1 = self.wallet.create_self_transfer()
    602+        tx_child_1 = self.wallet.create_self_transfer(utxo_to_spend=tx_parent_1["new_utxo"])
    603+        peer_1.send_and_ping(msg_tx(tx_child_1["tx"]))
    604+        parent_orphans.append(tx_parent_1["tx"])
    605+        orphanage = node.getorphantxs()
    606+        assert_equal(len(orphanage), DEFAULT_MAX_ORPHAN_TRANSACTIONS)
    


    rkrux commented at 9:28 am on October 25, 2024:
    0        assert_equal(len(node.getorphantxs()), DEFAULT_MAX_ORPHAN_TRANSACTIONS)
    

    Storing in another variable is not necessary only for one time usage.

    You don’t need to invalidate ACKs only for this though.

  61. rkrux approved
  62. rkrux commented at 9:36 am on October 25, 2024: none

    ACK 5c299ecafe6f336cffa145d28036b04b87e26712

    Thanks for adding this test, it’s easy to follow through.

  63. DrahtBot requested review from tdb3 on Oct 25, 2024
  64. in test/functional/p2p_orphan_handling.py:580 in 5c299ecafe
    575+
    576+        node = self.nodes[0]
    577+        self.generate(self.wallet, 1)
    578+        peer_1 = node.add_p2p_connection(P2PInterface())
    579+
    580+        self.log.info("Check that orphanage is empty on start of test")
    


    instagibbs commented at 10:58 am on October 25, 2024:
    nit: logging here seems excessive considering a failure of the assert makes it obvious what went wrong
  65. instagibbs approved
  66. instagibbs commented at 11:01 am on October 25, 2024: member

    ACK 5c299ecafe6f336cffa145d28036b04b87e26712

    feel free to ignore nit

  67. tdb3 approved
  68. tdb3 commented at 11:12 am on October 25, 2024: contributor

    ACK 5c299ecafe6f336cffa145d28036b04b87e26712

    I would also re-ACK quickly if the changes recommended by @rkrux and @instagibbs were implemented, and DEFAULT_MAX_ORPHAN_TRANSACTIONS moved to test_framework/mempool_util.py

  69. achow101 commented at 8:24 pm on October 25, 2024: member
    ACK 5c299ecafe6f336cffa145d28036b04b87e26712
  70. achow101 merged this on Oct 25, 2024
  71. achow101 closed this on Oct 25, 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-03 15:12 UTC

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