test: Use single node in mempool_reorg.py #36663

pull maflcko wants to merge 3 commits into bitcoin:master from maflcko:2610-test-mempool-reorg changing 1 files +26 −45
  1. maflcko commented at 1:17 PM on October 26, 2026: member

    mempool_reorg.py is a bit confusing:

    • There is a trigger_reorg helper, but it is not used consistently.
    • It tests tx trickle delay on node1, but the global args have immediate tx relay configured for node0.
    • Using two nodes is not needed, in light of Python helpers to create forks and P2P connections.

    So fix all issues by using a single node and the Python helpers.

  2. test: refactor: Use trigger_reorg helper in mempool_reorg.py
    This avoids having to disconnect nodes, and to treat nodes as holding
    chains.
    
    Using the existing create_empty_fork and trigger_reorg is easier.
    fabf5c52cc
  3. test: Use single node in mempool_reorg.py
    The test used two nodes, which is confusing:
    
    * node[0] uses immediate tx relay via noban@127.0.0.1; However, this
      will only apply to incoming connections, not to outgoing ones.
    * The second test requires a peer without immediate tx relay, so it
      would be cleaner to not have any global setting for faster tx relay
      here.
    * Two nodes is not required for testing here. Creating and submitting
      forks, or p2p connections can be done with Python helpers.
    
    Using a single node also allows to remove a bunch of sync and connect
    calls.
    fa329d62c5
  4. test: Extract first test case in mempool_reorg.py
    Also fix inverted comment: "valid" should say "invalid".
    fa3aeb51cf
  5. DrahtBot renamed this:
    test: Use single node in mempool_reorg.py
    test: Use single node in mempool_reorg.py
    on Oct 26, 2026
  6. DrahtBot added the label Tests on Oct 26, 2026
  7. DrahtBot commented at 1:17 PM on October 26, 2026: contributor

    <!--e57a25ab6845829454e8d69fc972939a-->

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

    <!--006a51241073e994b41acfe9ec718e94-->

    External sites

    <!--021abf342d371248e50ceaed478a90ca-->

    Reviews

    See the guideline and AI policy for information on the review process.

    Type Reviewers
    ACK jpk68, mercie-ux, darosior, Waridi318

    If your review is incorrectly listed, please copy-paste <code>&lt;!--meta-tag:bot-skip--&gt;</code> into the comment that the bot should ignore.

    <!--5faf32d7da4f0f540f40219e4f7537a3-->

  8. jpk68 commented at 8:34 PM on October 27, 2026: contributor

    ACK fa3aeb51cfb1f664627730ccfded040a16ad2e91

  9. mercie-ux commented at 8:35 AM on October 28, 2026: contributor

    ACK fa3aeb51cfb1f664627730ccfded040a16ad2e91

    The new fork setup gives the same reorg shape as before, with the block containing tx_disconnected replaced by three empty fork blocks. I also confirmed the comment fix, since after the final invalidatedblock, sendrawtransaction(timelock_tx) is rejected as non-final. Removing the whitelist was also necessary, because putting -whitelist=noban@127.0.0.1 back makes peer1 receive 2 invs early and the relay test fails.

  10. darosior approved
  11. darosior commented at 6:30 PM on October 29, 2026: member

    utACK fa3aeb51cfb1f664627730ccfded040a16ad2e91

  12. Waridi318 commented at 4:14 AM on October 30, 2026: none

    ACK fa3aeb5

    Ran mempool_reorg.py locally on each of the three commits and it passes on all of them. Over three runs each runtime went from about 1.8s on master to about 0.86s with this PR, which makes sense with one node instead of two.

    As a sanity check, changing fork_length=3 to fork_length=1 in test_reorg_relay makes the assertion in trigger_reorg fail, confirming the fork is what drives the reorg.

    Non-blocking nits, could be a follow-up:

    • In test_reorg, the second self.log.info("Generate a block") is not followed by any block generation.
    • In test_reorg_relay, the comment "Create a child of that transaction" sits right below tx_before_reorg, but tx_child actually spends tx_disconnected. Naming the parent explicitly would make it clearer.
  13. maflcko commented at 4:45 AM on October 30, 2026: member

    Non-blocking nits, could be a follow-up:

    Both are unrelated to the changes here, so I'll leave this as-is for now to avoid review churn.


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-10-30 09:40 UTC