[RPC][mempool]: Add savemempool RPC #11099

pull greenaddress wants to merge 2 commits into bitcoin:master from greenaddress:dump_mempool_rpc changing 4 files +53 −3
  1. greenaddress commented at 6:25 PM on August 20, 2017: contributor

    Adds a simple parameterless rpc command to dump the mempool.

    Rationale:

    Sometimes there can be a crash for whatever reason (bug, power loss, etc) causing the mempool.dat file to not be saved.

    This change allows to script/cron the rpc call to have more regular saves to the file as well as cli/ad-hoc.

    This should solve issue https://github.com/bitcoin/bitcoin/issues/11086

  2. in src/rpc/blockchain.cpp:1549 in b83be8d2a4 outdated
    1541 | +            + HelpExampleCli("dumpmempool", "")
    1542 | +            + HelpExampleRpc("dumpmempool", "")
    1543 | +        );
    1544 | +
    1545 | +    DumpMempool();
    1546 | +    return "Mempool dumped";
    


    promag commented at 10:40 PM on August 20, 2017:

    This is not correct since it can fail.

  3. in src/rpc/blockchain.cpp:1539 in b83be8d2a4 outdated
    1530 | @@ -1531,6 +1531,21 @@ UniValue getchaintxstats(const JSONRPCRequest& request)
    1531 |      return ret;
    1532 |  }
    1533 |  
    1534 | +UniValue dumpmempool(const JSONRPCRequest& request)
    1535 | +{
    1536 | +    if (request.fHelp || request.params.size() > 0)
    1537 | +        throw std::runtime_error(
    1538 | +            "dumpmempool\n"
    1539 | +            "\nDumps to disk the mempool (mempool.dat).\n"
    


    promag commented at 10:41 PM on August 20, 2017:

    Remove the filename?

  4. promag commented at 10:44 PM on August 20, 2017: member

    Please add a test.

    The function can be changed to know if it failed or not.

  5. promag commented at 10:46 PM on August 20, 2017: member

    Suggestion, reword Add dumpmempool RPC.

  6. fanquake added the label RPC/REST/ZMQ on Aug 20, 2017
  7. greenaddress renamed this:
    [RPC][mempool]: add rpc command to dump the mempool to disk
    [RPC][mempool]: Add dumpmempool RPC
    on Aug 21, 2017
  8. greenaddress force-pushed on Aug 21, 2017
  9. greenaddress commented at 1:45 AM on August 21, 2017: contributor

    @promag thanks, updated as for feedback and squashed

  10. greenaddress force-pushed on Aug 21, 2017
  11. in src/rpc/blockchain.cpp:1571 in 07d3aacbcb outdated
    1567 | @@ -1552,6 +1568,7 @@ static const CRPCCommand commands[] =
    1568 |      { "blockchain",         "gettxoutsetinfo",        &gettxoutsetinfo,        true,  {} },
    1569 |      { "blockchain",         "pruneblockchain",        &pruneblockchain,        true,  {"height"} },
    1570 |      { "blockchain",         "verifychain",            &verifychain,            true,  {"checklevel","nblocks"} },
    1571 | +    { "blockchain",         "dumpmempool",            &dumpmempool,            true,  {} },
    


    promag commented at 8:25 AM on August 21, 2017:

    Sort, move before getblockchaininfo .

  12. in src/rpc/blockchain.cpp:1545 in 07d3aacbcb outdated
    1540 | +            "\nExamples:\n"
    1541 | +            + HelpExampleCli("dumpmempool", "")
    1542 | +            + HelpExampleRpc("dumpmempool", "")
    1543 | +        );
    1544 | +
    1545 | +    if (!DumpMempool())
    


    promag commented at 8:26 AM on August 21, 2017:

    Missing { }.

  13. in src/rpc/blockchain.cpp:1549 in 07d3aacbcb outdated
    1542 | +            + HelpExampleRpc("dumpmempool", "")
    1543 | +        );
    1544 | +
    1545 | +    if (!DumpMempool())
    1546 | +        throw JSONRPCError(RPC_INTERNAL_ERROR, "Unable to dump mempool to disk");
    1547 | +    return "Mempool dumped";
    


    promag commented at 8:27 AM on August 21, 2017:

    Nit, new line before return.

  14. promag commented at 8:30 AM on August 21, 2017: member

    I wonder if it should throw RPC_INTERNAL_ERROR, since DumpMempool handles it's errors.

    Please split in two commits:

    • Add return value to DumpMempool
    • Add dumpmempool RPC.
  15. greenaddress force-pushed on Aug 21, 2017
  16. greenaddress commented at 11:26 AM on August 21, 2017: contributor

    @promag thanks, updated as for feedback and split in two commits

    re: RPC_INTERNAL_ERROR - didn't immediately found something better, very open to suggestions

    Anything else you would add to the test?

  17. promag commented at 9:37 PM on August 21, 2017: member

    I meant maybe not throw, and have the bool in the response.

  18. greenaddress commented at 10:02 PM on August 21, 2017: contributor

    I think the condition is exceptional and deserve a throw of an exception & consistent with the other rpcs (though I don't know if there's a more appropriate exception for it)

  19. promag commented at 10:13 PM on August 21, 2017: member

    I almost agree with that if it wasn't the fact that the function doesn't throw.. but I have no strong opinion on that.

    If the throw stays, then maybe RPC_MISC_ERROR. See what causes RPC_INTERNAL_ERROR, sound like really bad excpetions.

  20. in src/rpc/blockchain.cpp:1539 in 6df6ce09e4 outdated
    1530 | @@ -1531,9 +1531,28 @@ UniValue getchaintxstats(const JSONRPCRequest& request)
    1531 |      return ret;
    1532 |  }
    1533 |  
    1534 | +UniValue dumpmempool(const JSONRPCRequest& request)
    1535 | +{
    1536 | +    if (request.fHelp || request.params.size() > 0)
    1537 | +        throw std::runtime_error(
    1538 | +            "dumpmempool\n"
    1539 | +            "\nDumps to disk the mempool.\n"
    


    jonasschnelli commented at 9:41 AM on August 22, 2017:

    I'm not the one to complain about this: but should it be `"Dumps the mempool to disk"?

  21. in src/rpc/blockchain.cpp:1549 in 6df6ce09e4 outdated
    1544 | +
    1545 | +    if (!DumpMempool()) {
    1546 | +        throw JSONRPCError(RPC_INTERNAL_ERROR, "Unable to dump mempool to disk");
    1547 | +    }
    1548 | +
    1549 | +    return "Mempool dumped";
    


    jonasschnelli commented at 9:42 AM on August 22, 2017:

    Because this is machine to machine communication, use true as ret val at this point?

  22. jonasschnelli changes_requested
  23. jonasschnelli commented at 9:43 AM on August 22, 2017: contributor

    Concept ACK

  24. greenaddress commented at 12:43 PM on August 22, 2017: contributor

    thanks @jonasschnelli - good points

    added a commit (which i think should be squashed at some point together with "Add dumpmempool RPC")

  25. in src/rpc/blockchain.cpp:1546 in d6322291eb outdated
    1541 | +            + HelpExampleCli("dumpmempool", "")
    1542 | +            + HelpExampleRpc("dumpmempool", "")
    1543 | +        );
    1544 | +
    1545 | +    if (!DumpMempool()) {
    1546 | +        throw JSONRPCError(RPC_INTERNAL_ERROR, "Unable to dump mempool to disk");
    


    promag commented at 3:28 AM on August 23, 2017:

    Maybe RPC_MISC_ERROR. See what causes RPC_INTERNAL_ERROR, sounds like really bad exceptions.

  26. jonasschnelli commented at 10:57 AM on August 23, 2017: contributor

    utACK cd0ea487422028bec1f5df62ab4c57909c2bcc90

    Maybe add an rational (possible use-cases) to the PR description.

  27. greenaddress commented at 11:56 AM on August 23, 2017: contributor

    @promag updated the exception, thanks @jonasschnelli updated the description. Please note your utACK points to a commit from @TheBlueMatt. GitHub also tells me there's some changes required, should I ignore that?

  28. in test/functional/mempool_dump.py:32 in 79fa1ffe39 outdated
      27 | +        self.num_nodes = 1
      28 | +        self.setup_clean_chain = True
      29 | +
      30 | +    def run_test(self):
      31 | +        self.log.debug("Verify mempool file doesn't exists")
      32 | +        mempooldat = self.options.tmpdir + "/node0/regtest/mempool.dat"
    


    MarcoFalke commented at 12:00 PM on August 23, 2017:

    Use os.path.join, so that it works on other operating systems as well.

  29. in test/functional/mempool_dump.py:33 in 79fa1ffe39 outdated
      28 | +        self.setup_clean_chain = True
      29 | +
      30 | +    def run_test(self):
      31 | +        self.log.debug("Verify mempool file doesn't exists")
      32 | +        mempooldat = self.options.tmpdir + "/node0/regtest/mempool.dat"
      33 | +        assert_raises(OSError, lambda: os.remove(mempooldat))
    


    MarcoFalke commented at 12:02 PM on August 23, 2017:

    Might use os.path.isfile for better readability.

  30. in test/functional/mempool_dump.py:35 in 79fa1ffe39 outdated
      30 | +    def run_test(self):
      31 | +        self.log.debug("Verify mempool file doesn't exists")
      32 | +        mempooldat = self.options.tmpdir + "/node0/regtest/mempool.dat"
      33 | +        assert_raises(OSError, lambda: os.remove(mempooldat))
      34 | +        self.log.debug("Dump mempool to disk")
      35 | +        assert_equal(self.nodes[0].dumpmempool(), True)
    


    MarcoFalke commented at 12:03 PM on August 23, 2017:

    nit: No need for assert_equal, you can just assert dumpmempool()

  31. in test/functional/mempool_dump.py:37 in 79fa1ffe39 outdated
      32 | +        mempooldat = self.options.tmpdir + "/node0/regtest/mempool.dat"
      33 | +        assert_raises(OSError, lambda: os.remove(mempooldat))
      34 | +        self.log.debug("Dump mempool to disk")
      35 | +        assert_equal(self.nodes[0].dumpmempool(), True)
      36 | +        assert_equal(os.path.isfile(mempooldat), True)
      37 | +        os.rename(self.options.tmpdir + "/node0/regtest", self.options.tmpdir + "/node0/regtest_bk")
    


    MarcoFalke commented at 12:04 PM on August 23, 2017:

    I don't think we allow the datadir to be moved while running. The tests should not rely on this.


    MarcoFalke commented at 12:05 PM on August 23, 2017:

    You might be able to achieve the same error condition by changing the file permissions, though.

  32. MarcoFalke commented at 12:06 PM on August 23, 2017: member

    Concept ACK, but I don't like the tests.

  33. MarcoFalke commented at 12:08 PM on August 23, 2017: member

    You might even combine the tests with the existing mempool persist test.

  34. greenaddress commented at 12:17 PM on August 23, 2017: contributor

    @MarcoFalke I tried with permissions and didn't work. I couldn't find another way to trigger the error.

    Will address the other feedback now

  35. in src/validation.cpp:4375 in 0ade83e962 outdated
    4367 | @@ -4368,9 +4368,11 @@ void DumpMempool(void)
    4368 |          RenameOver(GetDataDir() / "mempool.dat.new", GetDataDir() / "mempool.dat");
    4369 |          int64_t last = GetTimeMicros();
    4370 |          LogPrintf("Dumped mempool: %gs to copy, %gs to dump\n", (mid-start)*0.000001, (last-mid)*0.000001);
    4371 | +        return true;
    4372 |      } catch (const std::exception& e) {
    4373 |          LogPrintf("Failed to dump mempool: %s. Continuing anyway.\n", e.what());
    4374 |      }
    4375 | +    return false;
    


    jnewbery commented at 3:58 PM on August 23, 2017:

    Not sure what the convention is, or what's best practice, but to me having the return false statement within the catch block is more obvious.

  36. in test/functional/mempool_dump.py:21 in 0ade83e962 outdated
      16 | +
      17 | +"""
      18 | +
      19 | +from test_framework.test_framework import BitcoinTestFramework
      20 | +from test_framework.util import *
      21 | +import os
    


    jnewbery commented at 4:00 PM on August 23, 2017:

    nit: PEP8 import ordering please: std library imports first, then local project imports.

  37. in test/functional/mempool_dump.py:38 in 0ade83e962 outdated
      33 | +        mempooldat = os.path.join(regtestdir, 'mempool.dat')
      34 | +        assert not os.path.isfile(mempooldat)
      35 | +        self.log.debug("Dump mempool to disk")
      36 | +        assert self.nodes[0].dumpmempool()
      37 | +        assert os.path.isfile(mempooldat)
      38 | +        moveddir = os.path.join(self.options.tmpdir, 'node0', 'regtest_bk')
    


    jnewbery commented at 5:27 PM on August 23, 2017:

    I'm not sure if this failure test is necessary. If bitcoind can't write to its data directory, I'm sure all kinds of bad things happen.


    greenaddress commented at 6:57 PM on August 23, 2017:

    I think it makes sense to check that there is no file, you dump and there is a file.


    MarcoFalke commented at 9:32 PM on August 23, 2017:

    I think it makes sense to check that there is no file, you dump and there is a file.

    You do exactly this in the lines above. The comment is about assert_raises_jsonrpc, which raises due to the missing datadir. As mentioned earlier, this will likely introduce hard to reproduce test failures now or in the future.

    With the current flakiness of the test framework in mind I am against adding such a failure test.


    MarcoFalke commented at 9:35 PM on August 23, 2017:

    What you might try instead is to copy the dumped mempool from node0 to node1 and check that it can be loaded. (The nodes are not connected, but share the same blockchain)

    Anyway, I just noticed you are using a clean blockchain and dump the empty mempool. Might be better to populate it a bit.


    promag commented at 9:45 PM on August 23, 2017:

    A bit as in 1 transaction is enough? 😄


    greenaddress commented at 11:53 AM on August 24, 2017:

    @MarcoFalke I made that change (about to push commit) and moved the test to mempool_persist as advised - however your suggestion still doesn't test the exception so I left that in, can easily remove the last 4 lines of the test if other agrees is better to not have it.

  38. jnewbery commented at 5:30 PM on August 23, 2017: member

    If the throw stays, then maybe RPC_MISC_ERROR. See what causes RPC_INTERNAL_ERROR, sound like really bad excpetions.

    I think either is fine. bitcoind should always be able to write to its data directory, so I would say failure to do so counts as an internal error.

    Concept ACK, but I don't like the tests.

    I also don't like the test framework messing with bitcoind's data directory. I don't think the failure testcase is necessary. If bitcoind can't write to its datadirectory, there are more pressing issues than the RPC raising the correct error.

    Agree with @MarcoFalke that it might be a good idea to combine this with the mempool_persist.py test (if it can be done tidily).

  39. greenaddress commented at 6:57 PM on August 23, 2017: contributor

    @jnewbery thanks, addressed some feedback.

    Re: testing I also don't like messing with the datadir but unless someone has better suggestions the options are keeping it or removing it.

  40. jnewbery commented at 7:52 PM on August 23, 2017: member

    the options are keeping it or removing it.

    I vote for removing it

  41. promag commented at 9:20 PM on August 23, 2017: member

    bitcoind should always be able to write to its data directory @jnewbery DumpMempool() ignores failures, treats them irrelevant, hence my initial point of removing the throw in the RPC.

  42. greenaddress commented at 11:55 AM on August 24, 2017: contributor

    @MarcoFalke I've merged the tests and added your suggestion "copy the dumped mempool from node0 to node1 and check that it can be loaded. (The nodes are not connected, but share the same blockchain)"

    I left in the exception test for now.

  43. greenaddress force-pushed on Aug 24, 2017
  44. greenaddress force-pushed on Aug 27, 2017
  45. greenaddress commented at 8:32 PM on August 27, 2017: contributor

    Updated slightly the tests only: removed the ugly rename of the node directory in favor of using permissions to make it fail in the test @MarcoFalke Permissions initially didn't work because there was a rename involved from a tmp file but it works if I use permissions on the tmp file that gets renamed ('mempool.dat.new') so switched to that

    I also removed from the test some redundant asserts re: os.remove doing its job (it already throws if it can't find a file or fails to remove it)

  46. sipa commented at 6:13 AM on August 28, 2017: member

    utACK d0bfa6a11a66a8c08fe2630472546d0e60175fe3 @jonasschnelli Have your concerns been addressed?

  47. in test/functional/mempool_persist.py:94 in d0bfa6a11a outdated
      90 | @@ -85,5 +91,29 @@ def run_test(self):
      91 |          self.nodes.append(self.start_node(0, self.options.tmpdir))
      92 |          wait_until(lambda: len(self.nodes[0].getrawmempool()) == 5)
      93 |  
      94 | +        regtestdir0 = os.path.join(self.options.tmpdir, 'node0', 'regtest')
    


    jnewbery commented at 1:40 PM on August 28, 2017:

    Intermediate regtestdir0 variable not required. os.path.join() can take any number of arguments.

    Same for regtestdir1 below.


    greenaddress commented at 7:06 PM on August 29, 2017:

    Makes sense. Will submit a fix for it

  48. in test/functional/mempool_persist.py:89 in d0bfa6a11a outdated
      90 | @@ -85,5 +91,29 @@ def run_test(self):
      91 |          self.nodes.append(self.start_node(0, self.options.tmpdir))
      92 |          wait_until(lambda: len(self.nodes[0].getrawmempool()) == 5)
      93 |  
      94 | +        regtestdir0 = os.path.join(self.options.tmpdir, 'node0', 'regtest')
      95 | +        mempooldat0 = os.path.join(regtestdir0, 'mempool.dat')
      96 | +        regtestdir1 = os.path.join(self.options.tmpdir, 'node1', 'regtest')
      97 | +        mempooldat1 = os.path.join(regtestdir1, 'mempool.dat')
      98 | +        self.log.debug("Remove the mempool.dat file. Verify that dumpmempool to disk via RPC re-creates it")
    


    jnewbery commented at 1:41 PM on August 28, 2017:

    Supernit: I like logging in the test script to be 'info' level, so when running the test locally, progress can be seen on the console by default.


    greenaddress commented at 7:06 PM on August 29, 2017:

    All the other logs in the test are debug. Either we change them all or I don't think it makes sense for me to just change mine.

  49. in test/functional/mempool_persist.py:108 in d0bfa6a11a outdated
     103 | +        self.log.debug("Stop nodes, make node1 use mempool.dat from node0. Verify it has 5 transactions")
     104 | +        self.stop_nodes()
     105 | +        os.rename(mempooldat0, mempooldat1)
     106 | +        self.nodes.append(self.start_node(1, self.options.tmpdir))
     107 | +        # Give bitcoind a second to reload the mempool
     108 | +        time.sleep(1)
    


    jnewbery commented at 1:42 PM on August 28, 2017:

    No need for time.sleep() if using wait_until() below.


    greenaddress commented at 7:07 PM on August 29, 2017:

    I thought so too (and indeed it works without time.sleep()) - however the test has that as a pattern and I think we either remove it for the rest of the calls (at least within the same test) or it's inconsistent.


    jnewbery commented at 8:28 PM on August 29, 2017:

    I'm all for trying to match local style, but there's no benefit in copying bad patterns.

    The time.sleep in L76 should be removed (and the assert_equal() in L78 replaced with a wait_until()) in a different PR.

    The time.sleep in L85 serves a purpose - the mempool takes a while to load so we want to give it time before asserting it's empty. There's probably a better way of testing this, but we can't just replace the assert_equal() with a wait_until().

  50. jnewbery commented at 1:43 PM on August 28, 2017: member

    I much, much prefer using file permissions on the mempool.dat file instead of deleting directories.

    A few nits in the testcase, but otherwise looks great. Thanks for indulging all of my review comments :)

  51. greenaddress commented at 7:09 PM on August 29, 2017: contributor

    @jnewbery thanks! Keep in mind we are not doing permissions on the mempool.dat file as that doesn't work (the dump gets done on a tmp file which then replace the mempool.dat and ignores permissions so we are acting on the tmp file instead)

  52. jnewbery commented at 8:32 PM on August 29, 2017: member

    Keep in mind we are not doing permissions on the mempool.dat file as that doesn't work (the dump gets done on a tmp file which then replace the mempool.dat and ignores permissions so we are acting on the tmp file instead)

    Ah. Very crafty! Can you add a comment to the test to explain that (mempool.dat.new is an implementation detail - it could potentially be changed in future, breaking this test, so a comment would be helpful)

  53. greenaddress commented at 12:26 AM on August 30, 2017: contributor

    @jnewbery I added the comment and removed the sleep. I didn't change the logging debug vs info as that imho should be done in a separate PR for all the log statements in the file (i.e. better to be consistent for now)

  54. jnewbery commented at 6:51 PM on August 31, 2017: member

    New commits look great. Can you squash?

  55. greenaddress force-pushed on Aug 31, 2017
  56. greenaddress commented at 8:12 PM on August 31, 2017: contributor

    @jnewbery done, didn't rebase however happy to if needed

  57. ghost commented at 8:30 PM on August 31, 2017: none

    strictly q On Aug 20, 2017 9:46 PM, "GreenAddress" notifications@github.com wrote:

    @promag https://github.com/promag thanks, updated as for feedback and squashed

    — You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/bitcoin/bitcoin/pull/11099#issuecomment-323627960, or mute the thread https://github.com/notifications/unsubscribe-auth/AVfQPLGwbbeqOskROywlYWaVocTD-14rks5saOFhgaJpZM4O8sJC .

  58. in test/functional/mempool_persist.py:94 in 64d1ad84c1 outdated
      96 | +        self.log.debug("Remove the mempool.dat file. Verify that dumpmempool to disk via RPC re-creates it")
      97 | +        os.remove(mempooldat0)
      98 | +        assert self.nodes[0].dumpmempool()
      99 | +        assert os.path.isfile(mempooldat0)
     100 | +
     101 | +        self.log.debug("Stop nodes, make node1 use mempool.dat from node0. Verify it has 5 transactions")
    


    jnewbery commented at 2:00 PM on September 1, 2017:

    I think the intent of this section of the tests is to verify that the dumped mempool from the dumpmempool RPC contains all the transactions. Correct? The way it's written right now doesn't test this. The act of stopping node0 causes it to dump its mempool on shutdown, and hence this test is just a repeat of the test on line 77. I think you need to:

    • run dumpmempool on a running node
    • move that mempool.dat to a temp location
    • shutdown the node
    • move the mempool.dat back to the correct location
    • start the node
    • check that its mempool contains the correct transactions
  59. in test/functional/mempool_persist.py:107 in 64d1ad84c1 outdated
     102 | +        self.stop_nodes()
     103 | +        os.rename(mempooldat0, mempooldat1)
     104 | +        self.nodes.append(self.start_node(1, self.options.tmpdir))
     105 | +        wait_until(lambda: len(self.nodes[1].getrawmempool()) == 5)
     106 | +
     107 | +        self.log.debug("Force core to fail to save file to disk. Check it errors.")
    


    jnewbery commented at 2:01 PM on September 1, 2017:

    nit: debug message could be clearer. Perhaps:

    "Prevent bitcoind from writing mempool.dat to disk. Verify that `dumpmempool` fails"
    
  60. jnewbery commented at 2:01 PM on September 1, 2017: member

    Looks really good. Just a couple more nits (sorry!)

  61. jnewbery commented at 6:53 PM on September 1, 2017: member

    Needed slight rebase changes after #11121 (apologies - I keep making changes to the test_framework API).

    I've done that and pushed here: https://github.com/jnewbery/bitcoin/tree/pr11099 . Feel free to reset your branch onto that commit.

  62. greenaddress force-pushed on Sep 1, 2017
  63. greenaddress commented at 7:43 PM on September 1, 2017: contributor

    @jnewbery thank you! I've updated the PR with your rebase, no need to apologize especially as you did all the work :)

  64. jnewbery commented at 7:53 PM on September 1, 2017: member

    Tested ACK 67d307f606f54a01b8dd6d79ca45d08171d20ccc. Looks great. Thanks for sticking with this.

    Expect Travis to fail (for this and all other PRs) until #11215 is merged.

  65. in src/rpc/blockchain.cpp:1537 in 67d307f606 outdated
    1531 | @@ -1532,9 +1532,28 @@ UniValue getchaintxstats(const JSONRPCRequest& request)
    1532 |      return ret;
    1533 |  }
    1534 |  
    1535 | +UniValue dumpmempool(const JSONRPCRequest& request)
    1536 | +{
    1537 | +    if (request.fHelp || request.params.size() != 0)
    


    promag commented at 10:31 PM on September 1, 2017:

    Nit, add braces.

  66. promag commented at 10:47 PM on September 1, 2017: member

    There is only one test for dumpmempool failure, which is the can't write to mempool.dat.new. However there is another return false; inside the catch (which I can't understand why) that should be tested.

    Also, RenameOver() doesn't throw, and IMO we should fail if the mempool.dat can't be updated.

  67. luke-jr commented at 6:52 AM on September 2, 2017: member

    Suggest renaming it to savemempool or something.

    The name dumpmempool to me suggested the same outcome as getrawmempool...

  68. luke-jr referenced this in commit c263becfc8 on Sep 2, 2017
  69. luke-jr referenced this in commit f6bed74531 on Sep 2, 2017
  70. greenaddress commented at 6:49 PM on September 2, 2017: contributor

    @luke-jr changed the name, savemempool sounds better to me too. @promag added brackets.

    didn't squash and rename one commit yet but happy to when people are happy with the changes

  71. greenaddress renamed this:
    [RPC][mempool]: Add dumpmempool RPC
    [RPC][mempool]: Add savemempool RPC
    on Sep 2, 2017
  72. luke-jr referenced this in commit bfcfc9810e on Sep 3, 2017
  73. jonasschnelli approved
  74. jonasschnelli commented at 5:33 PM on September 3, 2017: contributor

    utACK 8ef87d253c88c2e19e875f9fec601159fb6da32f

  75. jnewbery commented at 4:03 PM on September 4, 2017: member

    utACK 8ef87d253c88c2e19e875f9fec601159fb6da32f

  76. MarcoFalke commented at 7:18 PM on September 5, 2017: member

    @greenaddress Will review after rebase

  77. in src/rpc/blockchain.cpp:1551 in 8ef87d253c outdated
    1546 | +
    1547 | +    if (!DumpMempool()) {
    1548 | +        throw JSONRPCError(RPC_MISC_ERROR, "Unable to dump mempool to disk");
    1549 | +    }
    1550 | +
    1551 | +    return true;
    


    MarcoFalke commented at 7:21 PM on September 5, 2017:

    This return value is not documented. And I think we shouldn't return anything on this rpc.


    promag commented at 7:36 PM on September 5, 2017:

    Right, since on failure an exception is raised, on success it can be void.


    jnewbery commented at 12:05 AM on September 6, 2017:

    Yes, it appears that many RPCs that perform an action which is expected to succeed return NullUniValue on success. See several of the methods in src/rpc/net.cpp for example.

  78. in test/functional/mempool_persist.py:91 in 8ef87d253c outdated
      85 | @@ -86,9 +86,9 @@ def run_test(self):
      86 |  
      87 |          mempooldat0 = os.path.join(self.options.tmpdir, 'node0', 'regtest', 'mempool.dat')
      88 |          mempooldat1 = os.path.join(self.options.tmpdir, 'node1', 'regtest', 'mempool.dat')
      89 | -        self.log.debug("Remove the mempool.dat file. Verify that dumpmempool to disk via RPC re-creates it")
      90 | +        self.log.debug("Remove the mempool.dat file. Verify that savemempool to disk via RPC re-creates it")
      91 |          os.remove(mempooldat0)
      92 | -        assert self.nodes[0].dumpmempool()
      93 | +        assert self.nodes[0].savemempool()
    


    promag commented at 7:35 PM on September 5, 2017:

    Remove assert.

  79. promag commented at 7:40 PM on September 5, 2017: member

    Please see my above comment.

  80. luke-jr referenced this in commit 1b896d06e8 on Sep 5, 2017
  81. Add return value to DumpMempool 467cbbcbfc
  82. Add savemempool RPC 1aa97ee088
  83. greenaddress force-pushed on Sep 6, 2017
  84. greenaddress commented at 7:52 AM on September 6, 2017: contributor

    rebased & squashed and reworded the second commit to the new savemempool name - a lot of thanks for all feedback @promag @jnewbery @MarcoFalke I changed the return value to NullUniValue (and accordingly updated the test)

  85. promag commented at 12:44 PM on September 6, 2017: member

    utACK 1aa97ee.

  86. jnewbery commented at 7:29 PM on September 6, 2017: member

    utACK 1aa97ee088ea03dd208be054c5ad9198c1f13329

  87. MarcoFalke commented at 8:52 PM on September 6, 2017: member

    @greenaddress Thanks for sticking with the pull. Quite a pain to go through so much review iterations.

  88. MarcoFalke merged this on Sep 6, 2017
  89. MarcoFalke closed this on Sep 6, 2017

  90. MarcoFalke referenced this in commit bc561b4b7d on Sep 6, 2017
  91. promag commented at 9:03 PM on September 6, 2017: member

    Quite a pain to go through so much review iterations.

    You mean fun? :trollface:

  92. greenaddress deleted the branch on Jul 17, 2018
  93. PastaPastaPasta referenced this in commit b2de08eb8b on Sep 23, 2019
  94. PastaPastaPasta referenced this in commit 76e99d9933 on Sep 24, 2019
  95. PastaPastaPasta referenced this in commit cec3f7db47 on Nov 19, 2019
  96. PastaPastaPasta referenced this in commit 1656c3a7dc on Nov 21, 2019
  97. PastaPastaPasta referenced this in commit 0dbbf1e693 on Dec 9, 2019
  98. PastaPastaPasta referenced this in commit 220ab17944 on Jan 1, 2020
  99. PastaPastaPasta referenced this in commit bd6d2b22ac on Jan 2, 2020
  100. PastaPastaPasta referenced this in commit 0a3536fda2 on Jan 2, 2020
  101. PastaPastaPasta referenced this in commit 06b28cdfbb on Jan 2, 2020
  102. PastaPastaPasta referenced this in commit f7e407b310 on Jan 2, 2020
  103. PastaPastaPasta referenced this in commit 82a7ea2cac on Jan 2, 2020
  104. PastaPastaPasta referenced this in commit aa5c8f0b1c on Jan 2, 2020
  105. PastaPastaPasta referenced this in commit 59e212eaf8 on Jan 3, 2020
  106. ckti referenced this in commit d39030129d on Mar 28, 2021
  107. gades referenced this in commit 09eacf6abb on Jun 30, 2021
  108. 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: 2026-04-13 15:15 UTC

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