Store mempool and prioritization data to disk #8448

pull sipa wants to merge 4 commits into bitcoin:master from sipa:dumpmempool changing 6 files +147 −7
  1. sipa commented at 4:16 am on August 3, 2016: member

    Fixes #8433 and builds upon #8392.

    This adds a file mempool.dat to the data directory, which is created every 10 minutes, and at shutdown. At startup, it is loaded after loading/reindexing/activation of blocks (in the background).

    It only grabs a mempool lock while copying and sorting mempool shared pointers (similar to responding to a mempool BIP35 message), which takes 50-100ms here for 1 GB mempool. Loading from disk seems to take up to dozens of seconds but happens in the background.

  2. fanquake commented at 4:53 am on August 3, 2016: member
    We’ll need to add mempool.dat to doc/files.md
  3. dcousens commented at 6:43 am on August 3, 2016: contributor
    Why not behind a command line flag?
  4. laanwj commented at 6:55 am on August 3, 2016: member

    Concept ACK.

    Why not behind a command line flag?

    Agreed. It can be enabled by default. But people may want to disable this functionality, the per-10 minute dump could interfere with benchmarks and such for example.

  5. in src/main.cpp: in 8e0313fb33 outdated
    6792@@ -6794,6 +6793,107 @@ ThresholdState VersionBitsTipState(const Consensus::Params& params, Consensus::D
    6793     return VersionBitsState(chainActive.Tip(), params, pos, versionbitscache);
    6794 }
    6795 
    6796+bool LoadMempool(void)
    6797+{
    6798+    FILE* filestr = fopen((GetDataDir() / "mempool.dat").c_str(), "r");
    


    laanwj commented at 6:58 am on August 3, 2016:
    .string().c_str()

    sipa commented at 7:02 am on August 3, 2016:
    Seems to work fine?

    paveljanik commented at 7:06 am on August 3, 2016:
    Nono, travis failed because of this (https://travis-ci.org/bitcoin/bitcoin/jobs/149377465#L2149).

    dcousens commented at 7:57 am on August 3, 2016:

    IIRC the fopen parameters are restrict (or often are in the impl), and assumed to be there for the lifetime of the file pointer… I don’t think this temporary holds those variants and might cause UB?

    I could be wrong. edit: that may only be in the C standard, not C++

    I suspect it is completely irrelevant, seeing how prevalent this pattern is throughout the code.


    sipa commented at 6:26 am on October 31, 2016:
    restrict means the argument is assumed not to alias any other parameter, I think?
  6. in src/main.cpp: in 8e0313fb33 outdated
    6792@@ -6794,6 +6793,107 @@ ThresholdState VersionBitsTipState(const Consensus::Params& params, Consensus::D
    6793     return VersionBitsState(chainActive.Tip(), params, pos, versionbitscache);
    6794 }
    6795 
    6796+bool LoadMempool(void)
    6797+{
    6798+    FILE* filestr = fopen((GetDataDir() / "mempool.dat").c_str(), "r");
    6799+    CAutoFile file(filestr, SER_DISK, CLIENT_VERSION);
    6800+    if (file.IsNull()) {
    6801+        return error("Failed to open mempool file from disk");
    


    laanwj commented at 6:59 am on August 3, 2016:
    I don’t think missing this file should be an error. I remember users being confused by errors about other files missing (peers.dat), which are simply generated by the application anyhow.

    sipa commented at 7:02 am on August 3, 2016:
    Good point.
  7. in src/main.cpp: in 8e0313fb33 outdated
    6804+    int64_t count = 0;
    6805+
    6806+    try {
    6807+        uint64_t version;
    6808+        file >> version;
    6809+        if (version != 1) {
    


    laanwj commented at 7:00 am on August 3, 2016:
    Please use a constant MEMPOOL_DUMP_VERSION or so

    sipa commented at 6:47 am on October 31, 2016:
    Will do.
  8. paveljanik commented at 7:30 am on August 3, 2016: contributor

    Concept ACK

    0000000e0  7a 8e 6e 84 83 ab c4 ca  20 fb 9b 88 ac 00 00 00  |z.n..... .......|
    1000000f0  00 00 00 00 00 0f 6a 0d  48 61 6c 6c 6f 55 62 69  |......j.HalloUbi|
    200000100  72 63 68 74 21 00 00 00  00 0d 9a a1 57 00 00 00  |rcht!.......W...|
    

    As we dump raw txes from the mempool, this will conflict with current status of “antivirus-compliant” storage and dumping mempool.dat can stop the bitcoind from running, ie. new DoS vector.

  9. paveljanik commented at 7:30 am on August 3, 2016: contributor
    2016-08-03 07:29:00 Dumped mempool: 1.9e-05s to copy, 0.005925s to dump
  10. laanwj commented at 8:35 am on August 3, 2016: member

    As we dump raw txes from the mempool, this will conflict with current status of “antivirus-compliant” storage and dumping mempool.dat can stop the bitcoind from running, ie. new DoS vector.

    A fair point. Though a missing, or corrupted mempool.dat should never cause bitcoind to stop running. At most this will lose the mempool contents (at next start) due to the file being quarantined.

  11. dcousens commented at 8:44 am on August 3, 2016: contributor
    More XOR?
  12. pstratem commented at 8:57 am on August 3, 2016: contributor
    Indeed this probably should be XOR’d with a random key.
  13. paveljanik commented at 10:05 am on August 3, 2016: contributor

    At most this will lose the mempool contents due to the file being quarantined.

    AV can be configured to stop bitcoind with a dialog: “This app is writing a virus to your disk. OK | Error”. This is outside of bitcoind

  14. laanwj added the label Mempool on Aug 3, 2016
  15. jonasschnelli commented at 2:16 pm on August 3, 2016: contributor

    Concept ACK and the code size is surprisingly small!

    The only thing that I miss (not directly related to this PR) is an opportunity to keep a history of some major mempool data (feerate, size, tx rate, etc.). Another option would be keeping ~24*6 dumps per day that would could be stored in file-diff-deltas to allow generating any types of statistics.

  16. morcos commented at 4:23 pm on August 3, 2016: member

    I don’t really see a huge benefit in doing this. It seems like unless you are immediately restarting, you’ll be wasting a lot of time trying to load already confirmed transactions or low fee spam. That said I don’t object to making it a command line argument, but I would suggest it default to off.

    What’s the rationale for running it every 10 minutes? You can copy it from one running node to start another or to handle crashes?

  17. paveljanik commented at 4:45 pm on August 3, 2016: contributor

    I think it should be off by default. And when it is, we can even skip XORing it, I think as it is expert level feature anyway.

    Or the other way: create a RPC to dump mempool and that’s all. But this way we loose the save-on-restart feature which is nice (which can be worked around by dumpmempool and restart).

  18. sipa commented at 5:36 pm on August 3, 2016: member

    @morcos The reason for dumping every 10 minutes is so that prioritization data is not lost in case of a crash.

    But perhaps we should have separate files for that. prioritization.dat which is continuously dumped (maybe only after mapDeltas changed?), and mempool.dat which is only saved at shutdown?

  19. MarcoFalke commented at 5:44 pm on August 3, 2016: member

    wasting a lot of time trying to load already confirmed transactions or low fee spam

    Could it help to save the current block height to the mempool.dat and then discard mempool.dat on start when current height > 3 + height when mempool was saved?

  20. jgarzik commented at 7:20 pm on August 3, 2016: contributor

    This has split into two threads, really:

    1. mempool persistence across restarts
    2. persisting prio deltas across restarts & crashes 2.1) side note - other state such as wallet locked coins (lockunspent) should be persisted also

    Persisting bits of state like prio deltas is useful, and seems applicable to a continuous-log or database solution, that can be restored at startup.

    As for mempool restore…

    Standard rhetorical questions: Who will really use mempool restore, and how often?

    • Historically, users really do not like features that pause shutdown for a long time. We spent time optimizing bitcoind shutdown in the past.
    • Dump on shutdown does not provide crash protection (as @sipa noted)
    • Alternatives to dump-on-shutdown involve a lot of disk traffic (logging or db soln) at runtime, and introduce additional I/O stress points for remote attackers to exploit.
    • Therefore, the only use case for dump-on-shutdown is a rapid node restart – if restart is not rapid, much of the data will be stale, only reloading slow-confirming transactions uninteresting to miners.
    • Someone restarting their node tends to be an expert-only or dev-only operation; normal field operation - unattended operation or standard user session - will never see this feature.

    mempool restore seems likely to be a little used, expert-only feature.

  21. dcousens commented at 9:36 pm on August 3, 2016: contributor

    mempool restore seems likely to be a little used, expert-only feature.

    Somewhat agreed, and as a regular ‘power’ user of bitcoind, I personally already have my own RPC calls equivalent to dumpmempool for this.

  22. gmaxwell commented at 1:32 am on August 4, 2016: contributor

    @jgarzik This is functionality directly requested by miners, the absence of it creates an operational burden because nodes then end up making small blocks after being restarted.

    persisting prio deltas across restarts & crashes

    This isn’t useful without the transactions themselves– peers will not re-relay transactions they previously sent. So you could save priorities, but all of them would be almost completely useless.

    users really do not like features that pause shutdown for a long time.

    Indeed, if it takes a long time that is an issue. But this should be writing no more than about 150 MB of data, which should take under a second. If it’s taking a long time then that needs to be addressed.

    One solution if that is an issue is to simply not write it at shutdown, but to only use the regular snapshots.

    and introduce additional I/O stress points for remote attackers to exploit

    I don’t follow how remote attackers interact here; it wouldn’t make sense to have any of this behavior be remotely triggerable.

    if restart is not rapid, much of the data will be stale,

    It takes several hours for a full mempool to lose its utility.

    I suppose it would be reasonable to not even bother trying to load it if it’s more than three days old.

    Mempool sync is also a bandwidth concern for future mempool sync efforts– if it’s lost on restart, than every quick restart would waste bandwidth.

    Similarly for block transmission– latency and bandwidth usage will be adversely effected if mempool is lost on restart. It takes about 12 hours in my tests for a node to recover its compact block reconstruction performance after restart, and it can take several seconds to accept a block due to the empty signature cache.

    These pressures against restart are an operational burden, because then you’re pressured to try to find ways to avoid restarting– e.g. running extra nodes, or avoiding changing settings.

    Separately, the cold mempool means that users and developers spend time in a non-representative state after they try changing settings; which makes it much harder to iterate around settings changes.

    ( Sorry if some of these points are redundant with #8433 )

  23. petertodd commented at 2:25 am on August 4, 2016: contributor

    Concept ACK, and a very useful feature!

    Though I’d suggest making it off by default for now so that nodes that don’t need this don’t have the risk of a bug creating a restart loop - less risk if we start in a clean state by default.

  24. pstratem commented at 2:58 am on August 4, 2016: contributor

    @petertodd With the exception of the priority deltas the transactions are going through normal mempool accept logic.

    I can’t see this causing a restart loop unless there’s a bug in the priority handling logic or a remotely exploitable DoS issue anyways.

  25. dcousens commented at 3:00 am on August 4, 2016: contributor

    I can’t see this causing a restart loop unless there’s a bug in the priority handling logic or a remotely exploitable DoS issue anyways.

    Which may only be trigger-able under particular circumstance, of which may be captured in the current mempool state?

  26. petertodd commented at 3:12 am on August 4, 2016: contributor

    @pstratem Hmm, that’s a good point. Also, as long as we’re only saving the mempool in a normal, user-triggered, shutdown all transactions in the saved mempool should be fine.

    I’ll take back my objection.

  27. luke-jr commented at 3:13 am on August 4, 2016: member

    It seems like unless you are immediately restarting, you’ll be wasting a lot of time trying to load already confirmed transactions or low fee spam.

    Eloipool does a save/restore state when it restarts, and one thing it does is write a timestamp early on in the dump. This way, when loading from the dump, it can see if the data is irrelevant and ignore the file. Perhaps that would make sense here too?

    Any reason to write out the entire thing every interval, rather than just having another LevelDB database?

  28. jgarzik commented at 4:03 am on August 4, 2016: contributor

    @gmaxwell Those concerns seem to be met by remote mempool download also, which @morcos suggested elsewhere in the thread – and indeed was one original purpose of BIP 35 mempool message – maintaining miner’s mempools and not losing lucrative miner fees due to restart.

    Remote download over LAN is also potentially faster, something Google noticed when seeing increased performance through remote page caches: http://static.googleusercontent.com/media/research.google.com/en//pubs/archive/43886.pdf

    Remote download also gets you fresh transactions which the db/log will not have - fuller blocks, more miners fees.

    and introduce additional I/O stress points for remote attackers to exploit

    I don’t follow how remote attackers interact here; it wouldn’t make sense to have any of this behavior be remotely triggerable.

    The relevant portion that answers your confusion was elided: “Alternatives to dump-on-shutdown […]” This refers to, e.g. periodic dumps, streaming transactions to a leveldb or WAL log, which occur at runtime not shutdown.

  29. gmaxwell commented at 4:55 am on August 4, 2016: contributor

    Those concerns seem to be met by remote mempool download also, which @morcos suggested elsewhere in the thread – and indeed was one original purpose of BIP 35 mempool message – maintaining miner’s mempools and not losing lucrative miner fees due to restart.

    Preservation of the mempool is a prerequisite for mempool sync. Otherwise you’d have 150 MB of transfer (burning resources of remote nodes) each time someone restarts to twiddle some configure. I think the mempool message is unsuitable for synchronization generally, due to overhead.

    [and while the latency concerns related to compact blocks would be addressed by a bulk download, the bandwidth savings would be lost]

    Remote download over LAN is also potentially faster, something Google

    In Google datacenters not on our P2P network; in any case I believe the load is bottlenecked on any ordinary host. (and were it faster, it wouldn’t matter– resource usage needs to be heavily weighed).

    and introduce additional I/O stress points for remote attackers to exploit

    I don’t follow how remote attackers interact here; it wouldn’t make sense to have any of this behavior be remotely triggerable.

    The relevant portion that answers your confusion was elided: “Alternatives to dump-on-shutdown […]” This refers to, e.g. periodic dumps, streaming transactions to a leveldb or WAL log, which occur at runtime not shutdown.

    There isn’t any leveldb involved here; but regardless– I still don’t see where the “remote attackers” part that I was asking about comes in.

  30. petertodd commented at 5:05 am on August 4, 2016: contributor

    Notable how remote mempool load on startup could be increase the effects of a DoS attack due to all the extra bandwidth wasted as nodes restart after crashing; it’d be especially harmful if a remote crash exploit could be found if people ever setup nodes to restart automatically.

    On 3 August 2016 21:56:34 GMT-07:00, Gregory Maxwell notifications@github.com wrote:

    Those concerns seem to be met by remote mempool download also, which @morcos suggested elsewhere in the thread – and indeed was one original purpose of BIP 35 mempool message – maintaining miner’s mempools and not losing lucrative miner fees due to restart.

    Preservation of the mempool is a prerequisite for mempool sync. Otherwise you’d have 150 MB of transfer (burning resources of remote nodes) each time someone restarts to twiddle some configure. I think the mempool message is unsuitable for synchronization generally, due to overhead.

    Remote download over LAN is also potentially faster, something Google

    In Google datacenters not on our P2P network; in any case I believe the load is bottlenecked on any ordinary host. (and were it faster, it wouldn’t matter– resource usage needs to be heavily weighed).

    and introduce additional I/O stress points for remote attackers to exploit

    I don’t follow how remote attackers interact here; it wouldn’t make sense to have any of this behavior be remotely triggerable.

    The relevant portion that answers your confusion was elided: “Alternatives to dump-on-shutdown […]” This refers to, e.g. periodic dumps, streaming transactions to a leveldb or WAL log, which occur at runtime not shutdown.

    There isn’t any leveldb involved here; but regardless– I still don’t see where the “remote attackers” part that I was asking about comes in.


    You are receiving this because you were mentioned. Reply to this email directly or view it on GitHub: #8448 (comment)

  31. sipa commented at 5:28 am on August 4, 2016: member
    • Make it off by default: seems reasonable; not every node has a requirement to have a well-calibrated mempool immediately at startup. It does help for BIP152 block relay, but many nodes also likely won’t restart sufficiently fast to benefit.
    • XORing a key: sigh, ok
    • Checking how old the mempool is: height won’t work, as at the time you restart, you won’t have learned about blocks that have been found in the mean time. Using time would work, but meh… loading is fast and in the background
    • Using BIP35 instead: inefficient and unpredictable for resources (you don’t know the size of a remote mempool, and can’t tell them to not send 20 gigabytes worth of txids), and won’t work for prioritized transactions. I do think we should explore network-based mempool syncing independently, though.
    • Separating dumping priority data and mempool data: the problem is that for prioritized transactions, we need both, and there is no guaranteed way to load these from anywhere else. What about periodically dumping but only for prioritized transactions, and dumping the full mempool at shutdown (when configured).
    • Keeping historical record: much more complicated and can better be done in other ways (separate statistics module that persists to disk).
  32. gmaxwell commented at 5:35 am on August 4, 2016: contributor

    @sipa Could be off for now– though sad to lose the BIP152 improvement but as you say I guess most users aren’t going up and down that often and I suppose it could be defaulted on after mempool sync. Though I have a little concern that defaulting off would be another point of divergence between what virtually every developer runs and most users run.

    only for prioritized transactions,

    And their unconfirmed parents? meh.

  33. sipa commented at 5:37 am on August 4, 2016: member
    Idea: instead of not loading the mempool file when it’s too old, just skip loading entries that have expired by the time we load them. That has the same effect, and is a pure optimization.
  34. gmaxwell commented at 5:38 am on August 4, 2016: contributor
    sipa: sounds fine to me.
  35. jgarzik commented at 5:42 am on August 4, 2016: contributor

    Remote download over LAN is also potentially faster, something Google

    In Google datacenters not on our P2P network

    The P2P network is not a LAN. It was not suggested that miners download the mempool over a WAN. The referenced, driving use case is miners who requested this feature, with almost everyone else defaulting this feature ‘off’ In that context for that user subset, LAN environments are the norm.

    Furthermore, miners will inevitably want the fastest solution to node restart - thus the doc reference. Based on current LAN technology and research, all network with no additional disk I/O - either periodic (leveldb/log) or at startup/shutdown - is likely to be the performant solution.

    There isn’t any leveldb involved here

    Please re-read this thread. Several alternatives to dump-on-shutdown are discussed. Specifically, leveldb was suggested as an alternative solution, mostly recently a few comments back by @luke-jr My comment referenced these alternate solutions.

    This matches history, where the idea of storing the mempool in leveldb has been suggested many times over the years. It is a relevant discussion in the current thread context.

  36. jonasschnelli commented at 5:42 am on August 4, 2016: contributor

    XORing a key: sigh, ok

    I think this could be done in a follow up PR.

    […] Those concerns seem to be met by remote mempool download also, which @morcos suggested elsewhere in the thread – and indeed was one original purpose of BIP 35 mempool message – maintaining miner’s mempools and not losing lucrative miner fees due to restart.

    IMO BIP35’s mempool command is a fingerprinting and DOS attack vector. Its extremely resource hungry (some SPV nodes call the filtered mempool command over and over again).

    Also, since 0.13, we do disable the mempool p2p command when NODE_BLOOM is disabled. See #8078

  37. sipa commented at 5:44 am on August 4, 2016: member

    Furthermore, miners will inevitably want the fastest solution to node restart

    This PR does not slow down startup. The mempool file is loaded in the background, while the node is already running. Dumping takes a second on my VPS with pretty slow I/O.

  38. MarcoFalke commented at 9:30 am on August 4, 2016: member

    Idea: instead of not loading the mempool file when it’s too old, just skip loading entries that have expired by the time we load them. That has the same effect, and is a pure optimization.

    Assuming that skipping entries is extremely cheap, I no longer see a benefit in turning the feature off by default.

  39. sipa commented at 9:34 am on August 4, 2016: member
    The benefit of turning it off by default is still slightly faster shutdown (~1s in my own benchmarks on a slow system with large mempool), and lower disk usage (150 Mbyte by default is not much, but may matter for a pruning node).
  40. in src/main.cpp: in 8e0313fb33 outdated
    6823+            CAmount amountdelta = nFeeDelta;
    6824+            if (amountdelta) {
    6825+                mempool.PrioritiseTransaction(tx.GetHash(), tx.GetHash().ToString(), prioritydummy, amountdelta);
    6826+            }
    6827+            CValidationState state;
    6828+            AcceptToMemoryPool(mempool, state, tx, true, NULL, nTime, 0, false);
    


    jonasschnelli commented at 3:59 pm on August 4, 2016:
    Seems to require holding cs_main. AcceptToMemoryPoolWorker has a AssertLockHeld(cs_main);

    sipa commented at 6:46 am on October 31, 2016:
    Good point.
  41. btcdrak commented at 6:26 pm on August 4, 2016: contributor
    I feel very strongly this feature must be on by default. Not only is it extremely useful with practically no cost; it will have an impact in reducing overall p2p bandwidth consumption. There are a few hundred of nodes that regularly power on and off throughout the day. You could make the flush interval configurable but I don’t think that is necessary.
  42. dcousens commented at 7:44 pm on August 4, 2016: contributor

    it will have an impact in reducing overall p2p bandwidth consumption

    For the power cycles you refer to, [on average] how much of the mempool stays relevant? (no doubt also dependent on maxmempool)

  43. gmaxwell commented at 7:59 pm on August 4, 2016: contributor

    Btcdrak showed me some graphs showing that nodes often go on and off throughout the day.

    IMO the main benefit to turning it off is eliminating 2mbit/sec worth of extra writing that might reduce the life time of low end flash devices from the periodic writes. Perhaps only disable the periodic writes by default?

  44. dcousens commented at 8:31 pm on August 4, 2016: contributor
    @gmaxwell certainly even statoshi inv messages can show you there exists a 12 hourly periodical cycle for a large number of bitcoin P2P nodes. But arguing that some proportion of that could be “smoothed” by this feature I think might be a stretch.
  45. gmaxwell commented at 0:01 am on August 5, 2016: contributor
    @dcousens For BIP152 I observed that the obvious damage to the hitrate took about 12 hours to go away. so I’d imagine that benefits for bandwidth for preserving the mempool last that long. In theory they could last arbitrarily deep, though we can’t do compact block fetches of blocks far from the tip currently. (Right now it’s limited to ten blocks back from the tip IIRC).
  46. rebroad commented at 7:27 am on September 1, 2016: contributor
    I had been testing this for the last week or so, but I’ve had to remove it from my branch as it was causing strange behaviour - i.e. I couldn’t close the main GUI window, and although nodes were still being connected to, no blocks were being downloaded. bisect on both times this happened identified it to be the merge with this branch.
  47. gmaxwell commented at 9:45 pm on September 9, 2016: contributor
    Needs rebase.
  48. in src/init.cpp: in 8e0313fb33 outdated
    198@@ -199,6 +199,7 @@ void Shutdown()
    199     StopNode();
    200     StopTorControl();
    201     UnregisterNodeSignals(GetNodeSignals());
    202+    DumpMempool();
    


    luke-jr commented at 9:12 pm on October 4, 2016:
    IMO should do this after shutting down external interfaces (ZMQ).

    sipa commented at 6:47 am on October 31, 2016:
    Why?
  49. in src/init.cpp: in 8e0313fb33 outdated
    644@@ -644,6 +645,9 @@ void ThreadImport(std::vector<boost::filesystem::path> vImportFiles)
    645         LogPrintf("Stopping after block import\n");
    646         StartShutdown();
    647     }
    648+
    649+    LoadMempool();
    650+    ScheduleDumpMempool(*scheduler);
    


    luke-jr commented at 9:13 pm on October 4, 2016:
    If we’re going to dereference scheduler unconditionally, it should be passed as a reference rather than a pointer.

    sipa commented at 6:47 am on October 31, 2016:
    I’m dropping the scheduler in a rebase.
  50. in src/main.cpp: in 8e0313fb33 outdated
    2758@@ -2758,7 +2759,7 @@ bool static DisconnectTip(CValidationState& state, const CChainParams& chainpara
    2759             // ignore validation errors in resurrected transactions
    2760             list<CTransaction> removed;
    2761             CValidationState stateDummy;
    2762-            if (tx.IsCoinBase() || !AcceptToMemoryPool(mempool, stateDummy, tx, false, NULL, true)) {
    2763+            if (tx.IsCoinBase() || !AcceptToMemoryPool(mempool, stateDummy, tx, false, NULL, block.nTime, true, 0)) {
    


    luke-jr commented at 9:16 pm on October 4, 2016:
    What is the reasoning for using the reorg’d-out block timestamp as the accept time? Seems like it might defeat the purpose of resurrecting it in the first place?

    sipa commented at 6:48 am on October 31, 2016:
    Good point, will fix.
  51. in src/main.cpp: in 8e0313fb33 outdated
    6816+            CTransaction tx;
    6817+            int64_t nTime;
    6818+            int64_t nFeeDelta;
    6819+            file >> tx;
    6820+            file >> nTime;
    6821+            file >> nFeeDelta;
    


    luke-jr commented at 9:20 pm on October 4, 2016:
    Maybe the mempoolentry should just support serialisation?

    sipa commented at 6:35 am on October 31, 2016:
    That would be ugly. It’s an internal data structure with various indexes associated to it. It’s not the mempool entry that is stored - if it were, we wouldn’t need ATMP to load it back.
  52. in src/main.cpp: in 8e0313fb33 outdated
    6826+            }
    6827+            CValidationState state;
    6828+            AcceptToMemoryPool(mempool, state, tx, true, NULL, nTime, 0, false);
    6829+            count += state.IsValid();
    6830+        }
    6831+        std::map<uint256, CAmount> mapDeltas;
    


    luke-jr commented at 9:24 pm on October 4, 2016:
    This is missing priority deltas, which are currently only stored in mempool.mapDeltas (not on individual entries).

    sipa commented at 6:47 am on October 31, 2016:
    I don’t care.
  53. in src/main.h: in 8e0313fb33 outdated
    300@@ -299,7 +301,7 @@ void PruneAndFlush();
    301 
    302 /** (try to) add transaction to memory pool **/
    303 bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransaction &tx, bool fLimitFree,
    304-                        bool* pfMissingInputs, bool fOverrideMempoolLimit=false, const CAmount nAbsurdFee=0);
    305+                        bool* pfMissingInputs, int64_t nTime, bool fOverrideMempoolLimit, const CAmount nAbsurdFee);
    


    luke-jr commented at 9:26 pm on October 4, 2016:
    This might silently coerce boolean values intended for fOverrideMempoolLimit into nTime in merging code. Better to just put nTime at the end (or before an object that won’t coerce to/from it).

    sipa commented at 6:48 am on October 31, 2016:
    Good point. I’ll ad a temporary separate wrapper function for now.
  54. luke-jr changes_requested
  55. gmaxwell commented at 3:21 am on October 18, 2016: contributor
    0.14 is calling and it wants this functionality, trolls be damned.
  56. morcos commented at 3:46 am on October 18, 2016: member

    I’d really prefer if the every 10 minute scheduled dump was removed. I think useful features are:

    1. dump on clean shutdown
    2. dump on rpc request
    3. saving of prioritized transactions either via using 2 manually or a separate mechanism in the event of a crash

    The idea of not being able to get any of those benefits without having to write 100MB+ every 10 minutes kind of bothers me…

  57. gmaxwell commented at 3:51 am on October 18, 2016: contributor
    If there is an rpc request and you want 10 minute snapshots you just one while true; do bitcoin-cli snap ; sleep 600 ; done away from it.
  58. btcdrak commented at 7:05 am on October 18, 2016: contributor
    ACK on regular sync, system requirements are very low and the benefits are high. Worrying about a ~300MB file write every 10 minutes seems like micro optimisation to me. Would concerns go away if it was every 20 mins instead?
  59. laanwj commented at 9:10 pm on October 18, 2016: member

    I agree with @morcos. I’d also prefer not to do the automatic periodic writing, but just on shutdown, and when prompted through RPC. Bitcoind generates enough I/O as it is :( Could enable this only when there is prioritization data to save in the first place?

    If it is to be enabled by default, at the least there needs to be an option to disable it, e.g. for when benchmarking/measuring.

  60. sipa commented at 9:21 pm on October 18, 2016: member
    Ok, I’ll remove the automatic dumping.
  61. gmaxwell commented at 1:48 am on October 31, 2016: contributor
    @sipa ping
  62. Add feedelta to TxMempoolInfo c3efb58622
  63. Add AcceptToMemoryPoolWithTime function ced7c949e8
  64. sipa force-pushed on Oct 31, 2016
  65. sipa force-pushed on Oct 31, 2016
  66. sipa commented at 7:04 am on October 31, 2016: member

    Rebased with the following changes:

    • Several nits addressed (missing lock, add version constant, no big screamy errors on failure).
    • Periodic dump is gone; it only happens at shutdown now.
    • Expired entries are skipped on load (making a load of a week-old mempool.dat instantaneous).

    XORed dump is not implemented, this can be done later. As the regular dump seemed controversial, I’ve removed it now (it can always be added back later).

  67. Add DumpMempool and LoadMempool 3f78562df5
  68. Add mempool.dat to doc/files.md 582068aa90
  69. sipa force-pushed on Oct 31, 2016
  70. in src/main.cpp: in 582068aa90
    7040+        file << mapDeltas;
    7041+        FileCommit(file.Get());
    7042+        file.fclose();
    7043+        RenameOver(GetDataDir() / "mempool.dat.new", GetDataDir() / "mempool.dat");
    7044+        int64_t last = GetTimeMicros();
    7045+        LogPrintf("Dumped mempool: %gs to copy, %gs to dump\n", (mid-start)*0.000001, (last-mid)*0.000001);
    


    paveljanik commented at 8:33 am on November 1, 2016:

    This results in

    02016-11-01 08:30:08 Dumped mempool: 1.9e-05s to copy, 0.006452s to dump
    

    here on testnet. What about using ms instead?

  71. paveljanik commented at 8:35 am on November 1, 2016: contributor

    ACK https://github.com/bitcoin/bitcoin/pull/8448/commits/582068aa907127c12db53fbd65667dc7810d42b0

    XOR dumping nit can be ignored now, because we are dumping mempool on shutdown only.

  72. MarcoFalke added this to the milestone 0.14.0 on Nov 1, 2016
  73. laanwj merged this on Nov 2, 2016
  74. laanwj closed this on Nov 2, 2016

  75. laanwj referenced this in commit 101c642bef on Nov 2, 2016
  76. morcos commented at 2:55 pm on November 11, 2016: member
    @sipa sorry for commenting on this late, but could we have made it a bit more efficient by storing mapDeltas before the transactions, so then we don’t have to do 2 loops of prioritiseTransaction? not sure if its worth it to change now….
  77. paveljanik commented at 8:24 pm on November 11, 2016: contributor
    @morcos This is not in released version, so I think if there is a benefit, we can still change it. And of course, we can safely ignore this file every time…
  78. luke-jr referenced this in commit b9bb331a0a on Dec 21, 2016
  79. luke-jr referenced this in commit 25642bafa6 on Dec 21, 2016
  80. luke-jr referenced this in commit bbc36f61da on Dec 21, 2016
  81. luke-jr referenced this in commit 7e4b10beb3 on Dec 21, 2016
  82. codablock referenced this in commit 343cb52ea5 on Sep 19, 2017
  83. codablock referenced this in commit 0a0e60c1fb on Jan 13, 2018
  84. andvgal referenced this in commit f6cbeea2df on Jan 6, 2019
  85. CryptoCentric referenced this in commit c849add1f7 on Feb 15, 2019
  86. furszy referenced this in commit 1f010c0969 on Jan 23, 2021
  87. DrahtBot locked this on Aug 16, 2022

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-07-05 19:13 UTC

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