qa: Sync with validationinterface queue in sync_mempools #12206

pull MarcoFalke wants to merge 1 commits into bitcoin:master from MarcoFalke:Mf1801-qaWalletMempoolAsync changing 2 files +21 −1
  1. MarcoFalke commented at 1:18 am on January 17, 2018: member

    Commit e545dedf72bff2bd41c93c93eb576929fce37112 moved TransactionAddedToMempool to the background scheduler thread. Thus, adding a transaction to the mempool will no longer add it to the wallet immediately. Functional tests, that sync_mempools and then call into wallet rpcs will race against the scheduler thread.

    Fix that race by flushing the scheduler queue.

    Fixes #12205; Fixes #12171; References #9584;

  2. MarcoFalke added the label Tests on Jan 17, 2018
  3. MarcoFalke added this to the milestone 0.16.0 on Jan 17, 2018
  4. MarcoFalke commented at 1:33 am on January 17, 2018: member
    Obviously all other functional tests are affected as well. I will try to fix them in a later commit, but the above fix is needed the most as it is almost always failing on travis.
  5. promag commented at 1:35 am on January 17, 2018: member
    Concept ACK. Not sure the test should handle this way. IMO some sync_mempool(flush_scheduler=True) would be better?
  6. MarcoFalke commented at 1:50 am on January 17, 2018: member

    Yeah. Maybe an alternative would be to always catch up with the queue?

     0--- a/src/wallet/wallet.cpp
     1+++ b/src/wallet/wallet.cpp
     2@@ -1279,23 +1279,7 @@ void CWallet::BlockUntilSyncedToCurrentChain() {
     3     AssertLockNotHeld(cs_main);
     4     AssertLockNotHeld(cs_wallet);
     5 
     6-    {
     7-        // Skip the queue-draining stuff if we know we're caught up with
     8-        // chainActive.Tip()...
     9-        // We could also take cs_wallet here, and call m_last_block_processed
    10-        // protected by cs_wallet instead of cs_main, but as long as we need
    11-        // cs_main here anyway, its easier to just call it cs_main-protected.
    12-        LOCK(cs_main);
    13-        const CBlockIndex* initialChainTip = chainActive.Tip();
    14-
    15-        if (m_last_block_processed->GetAncestor(initialChainTip->nHeight) == initialChainTip) {
    16-            return;
    17-        }
    18-    }
    19-
    20-    // ...otherwise put a callback in the validation interface queue and wait
    21-    // for the queue to drain enough to execute it (indicating we are caught up
    22-    // at least with the time we entered this function).
    23+    // Wait for the queue to catch up on everything that was there when we entered this function
    24     SyncWithValidationInterfaceQueue();
    25 }
    

    Though, I am not sure how useful that is outside of functional tests.

  7. meshcollider commented at 11:38 am on January 17, 2018: contributor

    I think @promag was suggesting a different way for the tests to handle it, not to change the core code btw.

    Current approach seems fine to me at least for now, utACK https://github.com/bitcoin/bitcoin/pull/12206/commits/fadc3f6249a9eddaa3078e570a4465162032195e

  8. MarcoFalke commented at 1:29 pm on January 17, 2018: member
    I am not aware of a way to flush the scheduler from outside the code without modifying the code or mining a block. Though, I might be misssing something.
  9. promag commented at 1:54 pm on January 17, 2018: member

    I was suggesting adding a RPC to just do SyncWithValidationInterfaceQueue or whatever.

    Feels weird to replace assertions with poll.

  10. MarcoFalke commented at 3:43 pm on January 17, 2018: member
    Yes, I plan to do something like that after branch off of 0.16. At this point I’d feel bad to delay 0.16 by spawning unnecessary review-load on the queue.
  11. TheBlueMatt commented at 9:05 pm on January 17, 2018: member
    I agree with @promag here, and that fix should be just as/more simple/obvious than even this fix. Just add an RPC that calls SyncWithValidationInterfaceQueue() and call that at the end of sync_mempools(), at least then its much more obvious the fix is complete, and should require a lower review burden.
  12. ryanofsky commented at 9:29 pm on January 17, 2018: member
    utACK fadc3f6249a9eddaa3078e570a4465162032195e. I agree with everybody else that this should definitely be followed up on, but this fix is small and simple, and the test is failing constantly on travis, so it seems odd to object to merging this as a workaround.
  13. qa: Sync with validationinterface queue in sync_mempools fa1e69e52b
  14. MarcoFalke force-pushed on Jan 17, 2018
  15. MarcoFalke added the label RPC/REST/ZMQ on Jan 17, 2018
  16. MarcoFalke renamed this:
    qa: Have wallet wait for TransactionAddedToMempool
    qa: Sync with validationinterface queue in sync_mempools
    on Jan 17, 2018
  17. MarcoFalke commented at 9:50 pm on January 17, 2018: member
    Introduced the new syncwithvalidationinterfacequeue rpc as requested by @TheBlueMatt and @promag
  18. in src/rpc/blockchain.cpp:1647 in fa1e69e52b
    1643@@ -1628,6 +1644,7 @@ static const CRPCCommand commands[] =
    1644     { "hidden",             "waitfornewblock",        &waitfornewblock,        {"timeout"} },
    1645     { "hidden",             "waitforblock",           &waitforblock,           {"blockhash","timeout"} },
    1646     { "hidden",             "waitforblockheight",     &waitforblockheight,     {"height","timeout"} },
    1647+    { "hidden",             "syncwithvalidationinterfacequeue", &syncwithvalidationinterfacequeue, {} },
    


    promag commented at 9:58 pm on January 17, 2018:
    Sort, alignment… :trollface:
  19. promag commented at 10:01 pm on January 17, 2018: member
    Sweet utACK fadc3f6.
  20. ryanofsky commented at 10:09 pm on January 17, 2018: member
    utACK fa1e69e52bf8de08b1ce7a774416aa7a8d20068b. @TheBlueMatt was right, the new fix is more simple and obvious than the old one.
  21. in src/rpc/blockchain.cpp:327 in fa1e69e52b
    323@@ -323,6 +324,21 @@ UniValue waitforblockheight(const JSONRPCRequest& request)
    324     return ret;
    325 }
    326 
    327+UniValue syncwithvalidationinterfacequeue(const JSONRPCRequest& request)
    


    promag commented at 0:45 am on January 18, 2018:
    Not sure but src/rpc/misc.cpp is a better place?

    MarcoFalke commented at 1:24 am on January 18, 2018:
    My understanding is that blockchain.cpp also contains mempool rpcs. And this one is about mempool, no?

    promag commented at 1:32 am on January 18, 2018:
    Ok.
  22. in test/functional/test_framework/util.py:393 in fa1e69e52b
    389@@ -390,7 +390,7 @@ def sync_chain(rpc_connections, *, wait=1, timeout=60):
    390         timeout -= wait
    391     raise AssertionError("Chain sync failed: Best block hashes don't match")
    392 
    393-def sync_mempools(rpc_connections, *, wait=1, timeout=60):
    394+def sync_mempools(rpc_connections, *, wait=1, timeout=60, flush_scheduler=True):
    


    promag commented at 0:47 am on January 18, 2018:
    How about not making it optional? If there is such need in the future, add it then?

    MarcoFalke commented at 1:22 am on January 18, 2018:
    Right now it is overkilling, i.e. always flushing. But that is not necessary, as for non-wallet functional tests and also most wallet functional test it can be turned off. I will leave the “turning it off” for later.

    promag commented at 1:29 am on January 18, 2018:
    Ok, so minimal diff for now.
  23. MarcoFalke assigned laanwj on Jan 18, 2018
  24. laanwj merged this on Jan 18, 2018
  25. laanwj closed this on Jan 18, 2018

  26. laanwj referenced this in commit 898f560b55 on Jan 18, 2018
  27. laanwj commented at 2:06 pm on January 18, 2018: member
    utACK fa1e69e
  28. MarcoFalke deleted the branch on Jan 18, 2018
  29. jnewbery commented at 5:01 pm on January 22, 2018: member

    utACK fa1e69e52bf8de08b1ce7a774416aa7a8d20068b

    One comment: this places a brand new RPC in the mainline test setup path, which will make efforts like #12134 more difficult. I think binaries from commits prior to this will fail running any test scripts from this commit onwards, because the test code will try to call a non-existent RPC.

    Not a reason not to merge, but something to keep in mind.

  30. MarcoFalke commented at 6:11 pm on January 22, 2018: member

    @jnewbery This is true for every release, since every release adds new rpcs.

    Also it should be trivial to work around in python with a one or two-line change.

  31. jnewbery commented at 6:23 pm on January 22, 2018: member

    since every release adds new rpcs

    indeed, but not all RPCs are called in the mainline setup_nodes() method.

  32. MarcoFalke commented at 6:53 pm on January 22, 2018: member
    That looks like an overkill. Currently setup_network is only called after the chain was set up and I don’t think there are any plans to change this in the near future. Syncing the (empty) mempools just after a “fresh” chain was set up is probably just wasting time on travis.
  33. PastaPastaPasta referenced this in commit bfad945f7f on Jun 13, 2020
  34. PastaPastaPasta referenced this in commit 34ea4efebe on Jun 13, 2020
  35. PastaPastaPasta referenced this in commit b5ab77a266 on Jun 17, 2020
  36. PastaPastaPasta referenced this in commit a022cc5ec7 on Jun 18, 2020
  37. furszy referenced this in commit 307d7b1e5c on Feb 26, 2021
  38. MarcoFalke locked this on Sep 8, 2021

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-11-17 15:12 UTC

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