Repository navigation
backport: bitcoin#27460, #27585, #28168, #28200, #28218, #28284, #28289, #28369, #28637 #8071
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
acdca42
5f7b298
cf354cc
7ec810d
47e08b9
549000d
d64ec57
f65f4b0
c1ed90c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| - A new `importmempool` RPC has been added. It loads a valid `mempool.dat` file and attempts to | ||
| add its contents to the mempool. This can be useful to import mempool data from another node | ||
| without having to modify the datadir contents and without having to restart the node. (#8071) | ||
| - Warning: Importing untrusted files is dangerous, especially if metadata from the file is taken over. | ||
| - If you want to apply fee deltas, it is recommended to use the `getprioritisedtransactions` and | ||
| `prioritisetransaction` RPCs instead of the `apply_fee_delta_priority` option to avoid | ||
| double-prioritising any already-prioritised transactions in the mempool. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -171,6 +171,7 @@ | |
| using kernel::CoinStatsHashType; | ||
| using kernel::DEFAULT_STOPAFTERBLOCKIMPORT; | ||
| using kernel::DumpMempool; | ||
| using kernel::LoadMempool; | ||
| using kernel::ValidationCacheSizes; | ||
|
|
||
| using node::ApplyArgsManOptions; | ||
|
|
@@ -2489,11 +2490,17 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info) | |
| chainman.m_load_block = std::thread(&util::TraceThread, "loadblk", [=, &args, &chainman, &node] { | ||
| // ThreadImport can switch fReindex from true to false, fetch its original state here to use later | ||
| bool skip_evodb_repair_on_reindex = fReindex || fReindexChainState; | ||
| ThreadImport(chainman, vImportFiles, ShouldPersistMempool(args) ? MempoolPath(args) : fs::path{}); | ||
| ThreadImport(chainman, vImportFiles); | ||
|
|
||
| // Load mempool from disk | ||
| if (auto* pool{chainman.ActiveChainstate().GetMempool()}) { | ||
| LoadMempool(*pool, ShouldPersistMempool(args) ? MempoolPath(args) : fs::path{}, chainman.ActiveChainstate(), {}); | ||
| pool->SetLoadTried(!ShutdownRequested()); | ||
|
Comment on lines
+2493
to
+2498
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
🔴 Blocking: Skip the relocated mempool load after an aborted block import Moving LoadMempool outside ThreadImport bypasses the early returns that previously prevented it from running after shutdown or an import failure. During -reindex, the active tip starts null; if shutdown is requested before genesis is processed, LoadExternalBlockFile returns immediately and ThreadImport returns at blockstorage.cpp:942-944. This lambda nevertheless loads the saved mempool. A non-expired ordinary transaction reaches AcceptToMemoryPool and the Assert(m_active_chainstate.m_chain.Tip()) at validation.cpp:894, aborting instead of shutting down cleanly: LoadMempool checks ShutdownRequested only after processing that transaction (mempool_persist.cpp:111). The base tree skipped mempool loading on this path because the call was below ThreadImport's early returns. Check ShutdownRequested immediately after ThreadImport and return from the loader lambda before loading the mempool, or propagate import completion explicitly. source:
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is upstream's ordering from bitcoin#27460:
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Withdrawn (re-reviewed at
Comment on lines
+2497
to
+2498
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| } | ||
|
Comment on lines
+2493
to
+2499
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
|
||
| { | ||
| const CBlockIndex* tip = WITH_LOCK(::cs_main, return chainman.ActiveTip()); | ||
| const bool ibd = chainman.ActiveChainstate().IsInitialBlockDownload(); | ||
| const bool ibd = chainman.IsInitialBlockDownload(); | ||
| if (node.active_ctx) { | ||
| // On masternodes, defer the full broadcast until after | ||
| // nodeman->Init() so that GetProTxHash() is available | ||
|
|
@@ -2584,7 +2591,7 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info) | |
| // directly because the full broadcast (NetQuorum, | ||
| // ActiveContext) depends on a valid proTxHash. | ||
| const CBlockIndex* tip = WITH_LOCK(::cs_main, return chainman.ActiveTip()); | ||
| const bool ibd = chainman.ActiveChainstate().IsInitialBlockDownload(); | ||
| const bool ibd = chainman.IsInitialBlockDownload(); | ||
| GetMainSignals().InitializeCurrentBlockTip(tip, ibd); | ||
| } | ||
| }); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| // Copyright (c) 2016-present The Bitcoin Core developers | ||
| // Distributed under the MIT software license, see the accompanying | ||
| // file COPYING or https://opensource.org/license/mit/. | ||
|
|
||
| #include <kernel/mempool_removal_reason.h> | ||
|
|
||
| #include <cassert> | ||
| #include <string> | ||
|
|
||
| std::string RemovalReasonToString(const MemPoolRemovalReason& r) noexcept | ||
| { | ||
| switch (r) { | ||
| case MemPoolRemovalReason::EXPIRY: return "expiry"; | ||
| case MemPoolRemovalReason::SIZELIMIT: return "sizelimit"; | ||
| case MemPoolRemovalReason::REORG: return "reorg"; | ||
| case MemPoolRemovalReason::BLOCK: return "block"; | ||
| case MemPoolRemovalReason::CONFLICT: return "conflict"; | ||
| case MemPoolRemovalReason::MANUAL: return "manual"; | ||
| } | ||
| assert(false); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| // Copyright (c) 2016-present The Bitcoin Core developers | ||
| // Distributed under the MIT software license, see the accompanying | ||
| // file COPYING or https://opensource.org/license/mit/. | ||
|
|
||
| #ifndef BITCOIN_KERNEL_MEMPOOL_REMOVAL_REASON_H | ||
| #define BITCOIN_KERNEL_MEMPOOL_REMOVAL_REASON_H | ||
|
|
||
| #include <string> | ||
|
|
||
| /** Reason why a transaction was removed from the mempool, | ||
| * this is passed to the notification signal. | ||
| */ | ||
| enum class MemPoolRemovalReason { | ||
| EXPIRY, //!< Expired from mempool | ||
| SIZELIMIT, //!< Removed in size limiting | ||
| REORG, //!< Removed for reorganization | ||
| BLOCK, //!< Removed for block | ||
| CONFLICT, //!< Removed for conflict with in-block transaction | ||
| MANUAL //!< Removed manually | ||
| }; | ||
|
|
||
| std::string RemovalReasonToString(const MemPoolRemovalReason& r) noexcept; | ||
|
|
||
| #endif // BITCOIN_KERNEL_MEMPOOL_REMOVAL_REASON_H |
Uh oh!
There was an error while loading. Please reload this page.