Skip to content

Commit 4362ea3

Browse files
MarcoFalkeknst
authored andcommitted
Merge bitcoin#19826: Pass mempool reference to chainstate constructor
fa0572d Pass mempool reference to chainstate constructor (MarcoFalke) Pull request description: Next step toward bitcoin#19556 Instead of relying on the mempool global, each chainstate is given a reference to a mempool to keep up to date with the tip (block connections, disconnections, reorgs, ...) ACKs for top commit: promag: Code review ACK fa0572d. darosior: ACK fa0572d hebasto: ACK fa0572d, reviewed and tested on Linux Mint 20 (x86_64). Tree-SHA512: 12184d33ae5797438d03efd012a07ba3e4ffa0d817c7a0877743f3d7a7656fe279280c751554fc035ccd0058166153b6c6c308a98b2d6b13998922617ad95c4c
1 parent 5deca90 commit 4362ea3

File tree

7 files changed

+55
-35
lines changed

7 files changed

+55
-35
lines changed

src/init.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2021,7 +2021,7 @@ bool AppInitMain(const CoreContext& context, NodeContext& node, interfaces::Bloc
20212021
LOCK(cs_main);
20222022
node.evodb.reset();
20232023
node.evodb = std::make_unique<CEvoDB>(nEvoDbCache, false, fReset || fReindexChainState);
2024-
chainman.InitializeChainstate(llmq::chainLocksHandler, llmq::quorumInstantSendManager, llmq::quorumBlockProcessor, node.evodb);
2024+
chainman.InitializeChainstate(llmq::chainLocksHandler, llmq::quorumInstantSendManager, llmq::quorumBlockProcessor, node.evodb, *Assert(node.mempool));
20252025
chainman.m_total_coinstip_cache = nCoinCacheUsage;
20262026
chainman.m_total_coinsdb_cache = nCoinDBCache;
20272027

src/test/util/setup_common.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -168,10 +168,11 @@ ChainTestingSetup::ChainTestingSetup(const std::string& chainName, const std::ve
168168

169169
pblocktree.reset(new CBlockTreeDB(1 << 20, true));
170170

171-
m_node.chainman = &::g_chainman;
172-
173171
m_node.mempool = &::mempool;
174172
m_node.mempool->setSanityCheck(1.0);
173+
174+
m_node.chainman = &::g_chainman;
175+
175176
m_node.connman = std::make_unique<CConnman>(0x1337, 0x1337); // Deterministic randomness for tests.
176177

177178
::sporkManager = std::make_unique<CSporkManager>();
@@ -229,7 +230,7 @@ TestingSetup::TestingSetup(const std::string& chainName, const std::vector<const
229230
// instead of unit tests, but for now we need these here.
230231
RegisterAllCoreRPCCommands(tableRPC);
231232

232-
m_node.chainman->InitializeChainstate(llmq::chainLocksHandler, llmq::quorumInstantSendManager, llmq::quorumBlockProcessor, m_node.evodb);
233+
m_node.chainman->InitializeChainstate(llmq::chainLocksHandler, llmq::quorumInstantSendManager, llmq::quorumBlockProcessor, m_node.evodb, *m_node.mempool);
233234
::ChainstateActive().InitCoinsDB(
234235
/* cache_size_bytes */ 1 << 23, /* in_memory */ true, /* should_wipe */ false);
235236
assert(!::ChainstateActive().CanFlushToDisk());

src/test/validation_chainstate_tests.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ BOOST_FIXTURE_TEST_SUITE(validation_chainstate_tests, TestingSetup)
2525
BOOST_AUTO_TEST_CASE(validation_chainstate_resize_caches)
2626
{
2727
ChainstateManager manager;
28+
CTxMemPool mempool;
2829

2930
//! Create and add a Coin with DynamicMemoryUsage of 80 bytes to the given view.
3031
auto add_coin = [](CCoinsViewCache& coins_view) -> COutPoint {
@@ -39,7 +40,7 @@ BOOST_AUTO_TEST_CASE(validation_chainstate_resize_caches)
3940
return outp;
4041
};
4142

42-
CChainState& c1 = *WITH_LOCK(cs_main, return &manager.InitializeChainstate(llmq::chainLocksHandler, llmq::quorumInstantSendManager, llmq::quorumBlockProcessor, m_node.evodb));
43+
CChainState& c1 = *WITH_LOCK(cs_main, return &manager.InitializeChainstate(llmq::chainLocksHandler, llmq::quorumInstantSendManager, llmq::quorumBlockProcessor, m_node.evodb, mempool));
4344
c1.InitCoinsDB(
4445
/* cache_size_bytes */ 1 << 23, /* in_memory */ true, /* should_wipe */ false);
4546
WITH_LOCK(::cs_main, c1.InitCoinsCache(1 << 23));

src/test/validation_chainstatemanager_tests.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,13 @@ BOOST_FIXTURE_TEST_SUITE(validation_chainstatemanager_tests, ChainTestingSetup)
2828
BOOST_AUTO_TEST_CASE(chainstatemanager)
2929
{
3030
ChainstateManager& manager = *m_node.chainman;
31+
CTxMemPool &mempool = *m_node.mempool;
3132
std::vector<CChainState*> chainstates;
3233
const CChainParams& chainparams = Params();
3334

3435
// Create a legacy (IBD) chainstate.
3536
//
36-
CChainState& c1 = *WITH_LOCK(::cs_main, return &manager.InitializeChainstate(llmq::chainLocksHandler, llmq::quorumInstantSendManager, llmq::quorumBlockProcessor, m_node.evodb));
37+
CChainState& c1 = *WITH_LOCK(::cs_main, return &manager.InitializeChainstate(llmq::chainLocksHandler, llmq::quorumInstantSendManager, llmq::quorumBlockProcessor, m_node.evodb, mempool));
3738
chainstates.push_back(&c1);
3839
c1.InitCoinsDB(
3940
/* cache_size_bytes */ 1 << 23, /* in_memory */ true, /* should_wipe */ false);
@@ -59,7 +60,7 @@ BOOST_AUTO_TEST_CASE(chainstatemanager)
5960

6061
// Create a snapshot-based chainstate.
6162
//
62-
CChainState& c2 = *WITH_LOCK(::cs_main, return &manager.InitializeChainstate(llmq::chainLocksHandler, llmq::quorumInstantSendManager, llmq::quorumBlockProcessor, m_node.evodb, GetRandHash()));
63+
CChainState& c2 = *WITH_LOCK(::cs_main, return &manager.InitializeChainstate(llmq::chainLocksHandler, llmq::quorumInstantSendManager, llmq::quorumBlockProcessor, m_node.evodb, mempool, GetRandHash()));
6364
chainstates.push_back(&c2);
6465
c2.InitCoinsDB(
6566
/* cache_size_bytes */ 1 << 23, /* in_memory */ true, /* should_wipe */ false);
@@ -109,6 +110,7 @@ BOOST_AUTO_TEST_CASE(chainstatemanager)
109110
BOOST_AUTO_TEST_CASE(chainstatemanager_rebalance_caches)
110111
{
111112
ChainstateManager& manager = *m_node.chainman;
113+
CTxMemPool& mempool = *m_node.mempool;
112114
size_t max_cache = 10000;
113115
manager.m_total_coinsdb_cache = max_cache;
114116
manager.m_total_coinstip_cache = max_cache;
@@ -117,7 +119,7 @@ BOOST_AUTO_TEST_CASE(chainstatemanager_rebalance_caches)
117119

118120
// Create a legacy (IBD) chainstate.
119121
//
120-
CChainState& c1 = *WITH_LOCK(cs_main, return &manager.InitializeChainstate(llmq::chainLocksHandler, llmq::quorumInstantSendManager, llmq::quorumBlockProcessor, m_node.evodb));
122+
CChainState& c1 = *WITH_LOCK(cs_main, return &manager.InitializeChainstate(llmq::chainLocksHandler, llmq::quorumInstantSendManager, llmq::quorumBlockProcessor, m_node.evodb, mempool));
121123
chainstates.push_back(&c1);
122124
c1.InitCoinsDB(
123125
/* cache_size_bytes */ 1 << 23, /* in_memory */ true, /* should_wipe */ false);
@@ -135,7 +137,7 @@ BOOST_AUTO_TEST_CASE(chainstatemanager_rebalance_caches)
135137

136138
// Create a snapshot-based chainstate.
137139
//
138-
CChainState& c2 = *WITH_LOCK(cs_main, return &manager.InitializeChainstate(llmq::chainLocksHandler, llmq::quorumInstantSendManager, llmq::quorumBlockProcessor, m_node.evodb, GetRandHash()));
140+
CChainState& c2 = *WITH_LOCK(cs_main, return &manager.InitializeChainstate(llmq::chainLocksHandler, llmq::quorumInstantSendManager, llmq::quorumBlockProcessor, m_node.evodb, mempool, GetRandHash()));
139141
chainstates.push_back(&c2);
140142
c2.InitCoinsDB(
141143
/* cache_size_bytes */ 1 << 23, /* in_memory */ true, /* should_wipe */ false);
@@ -154,7 +156,6 @@ BOOST_AUTO_TEST_CASE(chainstatemanager_rebalance_caches)
154156
BOOST_CHECK_CLOSE(c1.m_coinsdb_cache_size_bytes, max_cache * 0.05, 1);
155157
BOOST_CHECK_CLOSE(c2.m_coinstip_cache_size_bytes, max_cache * 0.95, 1);
156158
BOOST_CHECK_CLOSE(c2.m_coinsdb_cache_size_bytes, max_cache * 0.95, 1);
157-
158159
}
159160

160161
BOOST_AUTO_TEST_SUITE_END()

src/test/validation_flush_tests.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,9 @@ BOOST_FIXTURE_TEST_SUITE(validation_flush_tests, BasicTestingSetup)
2222
//!
2323
BOOST_AUTO_TEST_CASE(getcoinscachesizestate)
2424
{
25+
CTxMemPool mempool;
2526
BlockManager blockman{};
26-
CChainState chainstate(blockman, llmq::chainLocksHandler, llmq::quorumInstantSendManager, llmq::quorumBlockProcessor, m_node.evodb);
27+
CChainState chainstate(blockman, llmq::chainLocksHandler, llmq::quorumInstantSendManager, llmq::quorumBlockProcessor, m_node.evodb, mempool);
2728
chainstate.InitCoinsDB(/*cache_size_bytes*/ 1 << 10, /*in_memory*/ true, /*should_wipe*/ false);
2829
WITH_LOCK(::cs_main, chainstate.InitCoinsCache(1 << 10));
2930
CTxMemPool tx_pool{};

src/validation.cpp

Lines changed: 30 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -433,9 +433,10 @@ static bool IsCurrentForFeeEstimation() EXCLUSIVE_LOCKS_REQUIRED(cs_main)
433433
* and instead just erase from the mempool as needed.
434434
*/
435435

436-
static void UpdateMempoolForReorg(DisconnectedBlockTransactions& disconnectpool, bool fAddToMempool) EXCLUSIVE_LOCKS_REQUIRED(cs_main, ::mempool.cs)
436+
static void UpdateMempoolForReorg(CTxMemPool& mempool, DisconnectedBlockTransactions& disconnectpool, bool fAddToMempool) EXCLUSIVE_LOCKS_REQUIRED(cs_main, mempool.cs)
437437
{
438438
AssertLockHeld(cs_main);
439+
AssertLockHeld(mempool.cs);
439440
std::vector<uint256> vHashUpdate;
440441
// disconnectpool's insertion_order index sorts the entries from
441442
// oldest to newest, but the oldest entry will be the last tx from the
@@ -1137,12 +1138,14 @@ CChainState::CChainState(BlockManager& blockman,
11371138
std::unique_ptr<llmq::CInstantSendManager>& isman,
11381139
std::unique_ptr<llmq::CQuorumBlockProcessor>& quorum_block_processor,
11391140
std::unique_ptr<CEvoDB>& evoDb,
1141+
CTxMemPool& mempool,
11401142
uint256 from_snapshot_blockhash)
11411143
: m_blockman(blockman),
11421144
m_clhandler(clhandler),
11431145
m_isman(isman),
11441146
m_quorum_block_processor(quorum_block_processor),
11451147
m_evoDb(evoDb),
1148+
m_mempool(mempool),
11461149
m_from_snapshot_blockhash(from_snapshot_blockhash) {}
11471150

11481151
void CChainState::InitCoinsDB(
@@ -2486,7 +2489,7 @@ bool CChainState::FlushStateToDisk(
24862489
{
24872490
bool fFlushForPrune = false;
24882491
bool fDoFullFlush = false;
2489-
CoinsCacheSizeState cache_state = GetCoinsCacheSizeState(&::mempool);
2492+
CoinsCacheSizeState cache_state = GetCoinsCacheSizeState(&m_mempool);
24902493
LOCK(cs_LastBlockFile);
24912494
if (fPruneMode && (fCheckForPruning || nManualPruneHeight > 0) && !fReindex) {
24922495
if (nManualPruneHeight > 0) {
@@ -2638,7 +2641,7 @@ static void AppendWarning(std::string& res, const std::string& warn)
26382641
}
26392642

26402643
/** Check warning conditions and do some notifications on new chain tip set. */
2641-
void static UpdateTip(const CBlockIndex *pindexNew, const CChainParams& chainParams, const CEvoDB& evoDb)
2644+
void static UpdateTip(CTxMemPool& mempool, const CBlockIndex *pindexNew, const CChainParams& chainParams, const CEvoDB& evoDb)
26422645
EXCLUSIVE_LOCKS_REQUIRED(::cs_main)
26432646
{
26442647
// New best block
@@ -2685,7 +2688,6 @@ void static UpdateTip(const CBlockIndex *pindexNew, const CChainParams& chainPar
26852688
GuessVerificationProgress(chainParams.TxData(), pindexNew), ::ChainstateActive().CoinsTip().DynamicMemoryUsage() * (1.0 / (1<<20)), ::ChainstateActive().CoinsTip().GetCacheSize(),
26862689
evoDb.GetMemoryUsage() * (1.0 / (1<<20)),
26872690
!warningMessages.empty() ? strprintf(" warning='%s'", warningMessages) : "");
2688-
26892691
}
26902692

26912693
/** Disconnect m_chain's tip.
@@ -2698,9 +2700,10 @@ void static UpdateTip(const CBlockIndex *pindexNew, const CChainParams& chainPar
26982700
* disconnectpool (note that the caller is responsible for mempool consistency
26992701
* in any case).
27002702
*/
2701-
bool CChainState::DisconnectTip(CValidationState& state, const CChainParams& chainparams, DisconnectedBlockTransactions *disconnectpool)
2703+
bool CChainState::DisconnectTip(CValidationState& state, const CChainParams& chainparams, DisconnectedBlockTransactions* disconnectpool)
27022704
{
27032705
AssertLockHeld(cs_main);
2706+
AssertLockHeld(m_mempool.cs);
27042707

27052708
CBlockIndex *pindexDelete = m_chain.Tip();
27062709
assert(pindexDelete);
@@ -2735,14 +2738,14 @@ bool CChainState::DisconnectTip(CValidationState& state, const CChainParams& cha
27352738
while (disconnectpool->DynamicMemoryUsage() > MAX_DISCONNECTED_TX_POOL_SIZE * 1000) {
27362739
// Drop the earliest entry, and remove its children from the mempool.
27372740
auto it = disconnectpool->queuedTx.get<insertion_order>().begin();
2738-
mempool.removeRecursive(**it, MemPoolRemovalReason::REORG);
2741+
m_mempool.removeRecursive(**it, MemPoolRemovalReason::REORG);
27392742
disconnectpool->removeEntry(it);
27402743
}
27412744
}
27422745

27432746
m_chain.SetTip(pindexDelete->pprev);
27442747

2745-
UpdateTip(pindexDelete->pprev, chainparams, *m_evoDb);
2748+
UpdateTip(m_mempool, pindexDelete->pprev, chainparams, *m_evoDb);
27462749
// Let wallets know transactions went from 1-confirmed to
27472750
// 0-confirmed or conflicted:
27482751
GetMainSignals().BlockDisconnected(pblock, pindexDelete);
@@ -2804,6 +2807,9 @@ class ConnectTrace {
28042807
bool CChainState::ConnectTip(CValidationState& state, const CChainParams& chainparams, CBlockIndex* pindexNew, const std::shared_ptr<const CBlock>& pblock, ConnectTrace& connectTrace, DisconnectedBlockTransactions &disconnectpool)
28052808
{
28062809
boost::posix_time::ptime start = boost::posix_time::microsec_clock::local_time();
2810+
AssertLockHeld(cs_main);
2811+
AssertLockHeld(m_mempool.cs);
2812+
28072813
assert(pindexNew->pprev == m_chain.Tip());
28082814
// Read block from disk.
28092815
int64_t nTime1 = GetTimeMicros();
@@ -2847,11 +2853,11 @@ bool CChainState::ConnectTip(CValidationState& state, const CChainParams& chainp
28472853
int64_t nTime5 = GetTimeMicros(); nTimeChainState += nTime5 - nTime4;
28482854
LogPrint(BCLog::BENCHMARK, " - Writing chainstate: %.2fms [%.2fs (%.2fms/blk)]\n", (nTime5 - nTime4) * MILLI, nTimeChainState * MICRO, nTimeChainState * MILLI / nBlocksTotal);
28492855
// Remove conflicting transactions from the mempool.;
2850-
mempool.removeForBlock(blockConnecting.vtx, pindexNew->nHeight);
2856+
m_mempool.removeForBlock(blockConnecting.vtx, pindexNew->nHeight);
28512857
disconnectpool.removeForBlock(blockConnecting.vtx);
28522858
// Update m_chain & related variables.
28532859
m_chain.SetTip(pindexNew);
2854-
UpdateTip(pindexNew, chainparams, *m_evoDb);
2860+
UpdateTip(m_mempool, pindexNew, chainparams, *m_evoDb);
28552861

28562862
int64_t nTime6 = GetTimeMicros(); nTimePostConnect += nTime6 - nTime5; nTimeTotal += nTime6 - nTime1;
28572863
LogPrint(BCLog::BENCHMARK, " - Connect postprocess: %.2fms [%.2fs (%.2fms/blk)]\n", (nTime6 - nTime5) * MILLI, nTimePostConnect * MICRO, nTimePostConnect * MILLI / nBlocksTotal);
@@ -2949,6 +2955,7 @@ void CChainState::PruneBlockIndexCandidates() {
29492955
bool CChainState::ActivateBestChainStep(CValidationState& state, const CChainParams& chainparams, CBlockIndex* pindexMostWork, const std::shared_ptr<const CBlock>& pblock, bool& fInvalidFound, ConnectTrace& connectTrace)
29502956
{
29512957
AssertLockHeld(cs_main);
2958+
AssertLockHeld(m_mempool.cs);
29522959

29532960
const CBlockIndex *pindexOldTip = m_chain.Tip();
29542961
const CBlockIndex *pindexFork = m_chain.FindFork(pindexMostWork);
@@ -2960,7 +2967,7 @@ bool CChainState::ActivateBestChainStep(CValidationState& state, const CChainPar
29602967
if (!DisconnectTip(state, chainparams, &disconnectpool)) {
29612968
// This is likely a fatal error, but keep the mempool consistent,
29622969
// just in case. Only remove from the mempool in this case.
2963-
UpdateMempoolForReorg(disconnectpool, false);
2970+
UpdateMempoolForReorg(m_mempool, disconnectpool, false);
29642971

29652972
// If we're unable to disconnect a block during normal operation,
29662973
// then that is a failure of our local system -- we should abort
@@ -3004,7 +3011,7 @@ bool CChainState::ActivateBestChainStep(CValidationState& state, const CChainPar
30043011
// A system error occurred (disk space, database error, ...).
30053012
// Make the mempool consistent with the current tip, just in case
30063013
// any observers try to use it before shutdown.
3007-
UpdateMempoolForReorg(disconnectpool, false);
3014+
UpdateMempoolForReorg(m_mempool, disconnectpool, false);
30083015
return false;
30093016
}
30103017
} else {
@@ -3021,9 +3028,9 @@ bool CChainState::ActivateBestChainStep(CValidationState& state, const CChainPar
30213028
if (fBlocksDisconnected) {
30223029
// If any blocks were disconnected, disconnectpool may be non empty. Add
30233030
// any disconnected transactions back to the mempool.
3024-
UpdateMempoolForReorg(disconnectpool, true);
3031+
UpdateMempoolForReorg(m_mempool, disconnectpool, true);
30253032
}
3026-
mempool.check(&CoinsTip());
3033+
m_mempool.check(&CoinsTip());
30273034

30283035
// Callbacks/notifications for a new best chain.
30293036
if (fInvalidFound)
@@ -3095,7 +3102,8 @@ bool CChainState::ActivateBestChain(CValidationState &state, const CChainParams&
30953102
LimitValidationInterfaceQueue();
30963103

30973104
{
3098-
LOCK2(cs_main, ::mempool.cs); // Lock transaction pool for at least as long as it takes for connectTrace to be consumed
3105+
LOCK(cs_main);
3106+
LOCK(m_mempool.cs); // Lock transaction pool for at least as long as it takes for connectTrace to be consumed
30993107
CBlockIndex* starting_tip = m_chain.Tip();
31003108
bool blocks_connected = false;
31013109
do {
@@ -3258,7 +3266,7 @@ bool CChainState::InvalidateBlock(CValidationState& state, const CChainParams& c
32583266
LimitValidationInterfaceQueue();
32593267

32603268
LOCK(cs_main);
3261-
LOCK(::mempool.cs); // Lock for as long as disconnectpool is in scope to make sure UpdateMempoolForReorg is called after DisconnectTip without unlocking in between
3269+
LOCK(m_mempool.cs); // Lock for as long as disconnectpool is in scope to make sure UpdateMempoolForReorg is called after DisconnectTip without unlocking in between
32623270
if (!m_chain.Contains(pindex)) break;
32633271
pindex_was_in_chain = true;
32643272
CBlockIndex *invalid_walk_tip = m_chain.Tip();
@@ -3278,7 +3286,7 @@ bool CChainState::InvalidateBlock(CValidationState& state, const CChainParams& c
32783286
// transactions back to the mempool if disconnecting was successful,
32793287
// and we're not doing a very deep invalidation (in which case
32803288
// keeping the mempool up to date is probably futile anyway).
3281-
UpdateMempoolForReorg(disconnectpool, /* fAddToMempool = */ (++disconnected <= 10) && ret);
3289+
UpdateMempoolForReorg(m_mempool, disconnectpool, /* fAddToMempool = */ (++disconnected <= 10) && ret);
32823290
if (!ret) return false;
32833291
assert(invalid_walk_tip->pprev == m_chain.Tip());
32843292

@@ -3414,7 +3422,7 @@ bool CChainState::MarkConflictingBlock(CValidationState& state, const CChainPara
34143422
}
34153423

34163424
{
3417-
LOCK(::mempool.cs); // Lock for as long as disconnectpool is in scope to make sure UpdateMempoolForReorg is called after DisconnectTip without unlocking in between
3425+
LOCK(m_mempool.cs); // Lock for as long as disconnectpool is in scope to make sure UpdateMempoolForReorg is called after DisconnectTip without unlocking in between
34183426
DisconnectedBlockTransactions disconnectpool;
34193427
while (m_chain.Contains(pindex)) {
34203428
const CBlockIndex* pindexOldTip = m_chain.Tip();
@@ -3424,7 +3432,7 @@ bool CChainState::MarkConflictingBlock(CValidationState& state, const CChainPara
34243432
if (!DisconnectTip(state, chainparams, &disconnectpool)) {
34253433
// It's probably hopeless to try to make the mempool consistent
34263434
// here if DisconnectTip failed, but we can try.
3427-
UpdateMempoolForReorg(disconnectpool, false);
3435+
UpdateMempoolForReorg(m_mempool, disconnectpool, false);
34283436
return false;
34293437
}
34303438
if (pindexOldTip == pindexBestHeader) {
@@ -3446,8 +3454,8 @@ bool CChainState::MarkConflictingBlock(CValidationState& state, const CChainPara
34463454

34473455
// DisconnectTip will add transactions to disconnectpool; try to add these
34483456
// back to the mempool.
3449-
UpdateMempoolForReorg(disconnectpool, true);
3450-
} // ::mempool.cs
3457+
UpdateMempoolForReorg(m_mempool, disconnectpool, true);
3458+
} // m_mempool.cs
34513459

34523460
// The resulting new best tip may not be in setBlockIndexCandidates anymore, so
34533461
// add it again.
@@ -5535,6 +5543,7 @@ CChainState& ChainstateManager::InitializeChainstate(std::unique_ptr<llmq::CChai
55355543
std::unique_ptr<llmq::CInstantSendManager>& isman,
55365544
std::unique_ptr<llmq::CQuorumBlockProcessor>& quorum_block_processor,
55375545
std::unique_ptr<CEvoDB>& evoDb,
5546+
CTxMemPool& mempool,
55385547
const uint256& snapshot_blockhash)
55395548
{
55405549
bool is_snapshot = !snapshot_blockhash.IsNull();
@@ -5545,7 +5554,7 @@ CChainState& ChainstateManager::InitializeChainstate(std::unique_ptr<llmq::CChai
55455554
throw std::logic_error("should not be overwriting a chainstate");
55465555
}
55475556

5548-
to_modify.reset(new CChainState(m_blockman, clhandler, isman, quorum_block_processor, evoDb, snapshot_blockhash));
5557+
to_modify.reset(new CChainState(m_blockman, clhandler, isman, quorum_block_processor, evoDb, mempool, snapshot_blockhash));
55495558

55505559
// Snapshot chainstates and initial IBD chaintates always become active.
55515560
if (is_snapshot || (!is_snapshot && !m_active_chainstate)) {

0 commit comments

Comments
 (0)