Skip to content

qa: Functional tests are intrinsically vulnerable to timeouts #19732

Open

Description

@hebasto

On master (3ab2582) with this patch:

--- a/src/net.cpp
+++ b/src/net.cpp
@@ -2868,7 +2868,7 @@ int64_t CConnman::PoissonNextSendInbound(int64_t now, int average_interval_secon
 
 int64_t PoissonNextSend(int64_t now, int average_interval_seconds)
 {
-    return now + (int64_t)(log1p(GetRand(1ULL << 48) * -0.0000000000000035527136788 /* -1/2^48 */) * average_interval_seconds * -1000000.0 + 0.5);
+    return now + (int64_t)(log1p(((1ULL << 48) - 1) * -0.0000000000000035527136788 /* -1/2^48 */) * average_interval_seconds * -1000000.0 + 0.5);
 }
 
 CSipHasher CConnman::GetDeterministicRandomizer(uint64_t id) const

a bunch of functional tests fail due to the timeout:

feature_notifications.py                | ✖ Failed  | 62 s
interface_rest.py                       | ✖ Failed  | 63 s
interface_zmq.py                        | ✖ Failed  | 64 s
mempool_persist.py                      | ✖ Failed  | 62 s
mempool_unbroadcast.py                  | ✖ Failed  | 32 s
p2p_blocksonly.py                       | ✖ Failed  | 61 s
p2p_feefilter.py                        | ✖ Failed  | 63 s
p2p_getaddr_caching.py                  | ✖ Failed  | 62 s
p2p_permissions.py                      | ✖ Failed  | 63 s
p2p_segwit.py                           | ✖ Failed  | 69 s
p2p_tx_download.py                      | ✖ Failed  | 75 s
rpc_deprecated.py                       | ✖ Failed  | 62 s
rpc_psbt.py                             | ✖ Failed  | 65 s
rpc_psbt.py --descriptors               | ✖ Failed  | 67 s
rpc_rawtransaction.py                   | ✖ Failed  | 64 s
wallet_abandonconflict.py               | ✖ Failed  | 63 s
wallet_balance.py                       | ✖ Failed  | 63 s
wallet_basic.py                         | ✖ Failed  | 68 s
wallet_basic.py --descriptors           | ✖ Failed  | 72 s
wallet_bumpfee.py                       | ✖ Failed  | 64 s
wallet_groups.py                        | ✖ Failed  | 62 s
wallet_implicitsegwit.py                | ✖ Failed  | 62 s
wallet_listreceivedby.py                | ✖ Failed  | 62 s
wallet_listtransactions.py              | ✖ Failed  | 62 s
wallet_resendwallettransactions.py      | ✖ Failed  | 62 s

Just bumping timeout values only decreases the probability of a new timeout failure occurrence.

Suggested solution #19588 was ugly and controversial, and it has being closed for now.

Related issues:

Activity

  1. changed the title [-]test: Functional tests are intrinsic vulnerable to timeouts[/-] [+]qa: Functional tests are intrinsic vulnerable to timeouts[/+] on Nov 6, 2020
  2. rebroad commented on Feb 26, 2022

    @rebroad
    Contributor

    bitcoin-core/gui#559 - I'm also getting a test failing in this PR, probably due to a timeout.

  3. Sjors commented on Feb 10, 2025

    @Sjors
    Member

    Is #31833 a symptom of this?

  4. mzumsande commented on Feb 10, 2025

    @mzumsande
    Contributor

    Is #31833 a symptom of this?

    I don't think so, just a missing sync there.

  5. maflcko commented on May 19, 2026

    @maflcko
    Member

    Just to give a status update on this: The issue still exists, however:

    • The CI normally has larger timeouts (due to slow runners+sanitizers+emulation), so the issue can't be seen there often, unless mocktime is used.
    • Many tests opt in to immediate tx relay, as they do not test the delay specifically.

    The current list of failing tests is smaller, probably:

    mempool_accept_wtxid.py                                                          | ✖ Failed  | 60 s
    mempool_limit.py                                                                 | ✖ Failed  | 64 s
    mempool_package_rbf.py                                                           | ✖ Failed  | 64 s
    mempool_persist.py                                                               | ✖ Failed  | 75 s
    mempool_reorg.py                                                                 | ✖ Failed  | 10 s
    p2p_blocksonly.py                                                                | ✖ Failed  | 61 s
    p2p_leak_tx.py --v1transport                                                     | ✖ Failed  | 61 s
    p2p_leak_tx.py --v2transport                                                     | ✖ Failed  | 61 s
    p2p_private_broadcast.py                                                         | ✖ Failed  | 65 s
    p2p_tx_download.py                                                               | ✖ Failed  | 29 s
    p2p_tx_privacy.py                                                                | ✖ Failed  | 61 s
    rpc_psbt.py                                                                      | ✖ Failed  | 84 s
    wallet_balance.py                                                                | ✖ Failed  | 68 s
    wallet_change_address.py                                                         | ✖ Failed  | 67 s
    wallet_conflicts.py                                                              | ✖ Failed  | 64 s
    

    The current diff to reproduce would be something like:

    diff --git a/src/net_processing.cpp b/src/net_processing.cpp
    index 631e968da7..0d3748f05c 100644
    --- a/src/net_processing.cpp
    +++ b/src/net_processing.cpp
    @@ -1177,3 +1177,3 @@ std::chrono::microseconds PeerManagerImpl::NextInvToInbounds(std::chrono::micros
         if (timer < now) {
    -        timer = now + m_rng.rand_exp_duration(average_interval);
    +        timer = now + 4min;
         }

    I wonder if a possible solution could be to:

    • use immediate tx relay in the tests that do not check the delay.
    • Use mocktime or a larger base-timeout for the other tests.
  6. Sjors commented on May 21, 2026

    @Sjors
    Member

    use immediate tx relay in the tests that do not check the delay

    This seems like a good idea.

  7. changed the title [-]qa: Functional tests are intrinsic vulnerable to timeouts[/-] [+]qa: Functional tests are intrinsically vulnerable to timeouts[/+] on May 21, 2026
  8. added a commit that references this issue on May 22, 2026
  9. added a commit that references this issue on Jun 28, 2026
  10. added a commit that references this issue on Jun 30, 2026
  11. added a commit that references this issue on Aug 19, 2026
  12. ronnakamoto commented on Sep 21, 2026

    @ronnakamoto

    Just to give a status update on this: The issue still exists, however:

    • The CI normally has larger timeouts (due to slow runners+sanitizers+emulation), so the issue can't be seen there often, unless mocktime is used.
    • Many tests opt in to immediate tx relay, as they do not test the delay specifically.

    The current list of failing tests is smaller, probably:

    mempool_accept_wtxid.py                                                          | ✖ Failed  | 60 s
    mempool_limit.py                                                                 | ✖ Failed  | 64 s
    mempool_package_rbf.py                                                           | ✖ Failed  | 64 s
    mempool_persist.py                                                               | ✖ Failed  | 75 s
    mempool_reorg.py                                                                 | ✖ Failed  | 10 s
    p2p_blocksonly.py                                                                | ✖ Failed  | 61 s
    p2p_leak_tx.py --v1transport                                                     | ✖ Failed  | 61 s
    p2p_leak_tx.py --v2transport                                                     | ✖ Failed  | 61 s
    p2p_private_broadcast.py                                                         | ✖ Failed  | 65 s
    p2p_tx_download.py                                                               | ✖ Failed  | 29 s
    p2p_tx_privacy.py                                                                | ✖ Failed  | 61 s
    rpc_psbt.py                                                                      | ✖ Failed  | 84 s
    wallet_balance.py                                                                | ✖ Failed  | 68 s
    wallet_change_address.py                                                         | ✖ Failed  | 67 s
    wallet_conflicts.py                                                              | ✖ Failed  | 64 s
    

    The current diff to reproduce would be something like:

    diff --git a/src/net_processing.cpp b/src/net_processing.cpp
    index 631e968da7..0d3748f05c 100644
    --- a/src/net_processing.cpp
    +++ b/src/net_processing.cpp
    @@ -1177,3 +1177,3 @@ std::chrono::microseconds PeerManagerImpl::NextInvToInbounds(std::chrono::micros
    if (timer < now) {

    •    timer = now + m_rng.rand_exp_duration(average_interval);
      
    •    timer = now + 12min;
      
      }
      I wonder if a possible solution could be to:
    • use immediate tx relay in the tests that do not check the delay.
    • Use mocktime or a larger base-timeout for the other tests.

    Hi @hebasto, I opened #36306 to address part of this issue.

    Following the approach suggested in the thread, it opts tests that don't test relay timing into immediate tx relay via noban_tx_relay = True, which whitelists the local peer and skips the Poisson-delayed relay.

  13. added a commit that references this issue on Oct 23, 2026
  14. maflcko commented on Oct 26, 2026

    @maflcko
    Member

    Just checking in here again, on current master, with the diff:

    diff --git a/src/net_processing.cpp b/src/net_processing.cpp
    index 14be69e227..ab2d494281 100644
    --- a/src/net_processing.cpp
    +++ b/src/net_processing.cpp
    @@ -1278,3 +1278,3 @@ std::chrono::microseconds PeerManagerImpl::NextInvToInbounds(std::chrono::micros
         if (timer < now) {
    -        timer = now + m_rng.rand_exp_duration(average_interval);
    +        timer = now + 4min;
         }

    the list is:

    p2p_blocksonly.py                                                                | ✖ Failed  | 62 s
    p2p_leak_tx.py --v1transport                                                     | ✖ Failed  | 62 s
    p2p_leak_tx.py --v2transport                                                     | ✖ Failed  | 62 s
    p2p_private_broadcast.py                                                         | ✖ Failed  | 66 s
    p2p_tx_download.py                                                               | ✖ Failed  | 20 s
    p2p_tx_privacy.py                                                                | ✖ Failed  | 61 s
    p2p_tx_relay_rate_limit.py                                                       | ✖ Failed  | 6 s
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions