Skip to content

Commit be2d50b

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 908267e commit be2d50b

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
@@ -2013,7 +2013,7 @@ bool AppInitMain(const CoreContext& context, NodeContext& node, interfaces::Bloc
20132013
LOCK(cs_main);
20142014
node.evodb.reset();
20152015
node.evodb = std::make_unique<CEvoDB>(nEvoDbCache, false, fReset || fReindexChainState);
2016-
chainman.InitializeChainstate(llmq::chainLocksHandler, llmq::quorumInstantSendManager, llmq::quorumBlockProcessor, node.evodb);
2016+
chainman.InitializeChainstate(llmq::chainLocksHandler, llmq::quorumInstantSendManager, llmq::quorumBlockProcessor, node.evodb, *Assert(node.mempool));
20172017
chainman.m_total_coinstip_cache = nCoinCacheUsage;
20182018
chainman.m_total_coinsdb_cache = nCoinDBCache;
20192019

src/test/util/setup_common.cpp

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

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

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

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

231-
m_node.chainman->InitializeChainstate(llmq::chainLocksHandler, llmq::quorumInstantSendManager, llmq::quorumBlockProcessor, m_node.evodb);
232+
m_node.chainman->InitializeChainstate(llmq::chainLocksHandler, llmq::quorumInstantSendManager, llmq::quorumBlockProcessor, m_node.evodb, *m_node.mempool);
232233
::ChainstateActive().InitCoinsDB(
233234
/* cache_size_bytes */ 1 << 23, /* in_memory */ true, /* should_wipe */ false);
234235
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
@@ -432,9 +432,10 @@ static bool IsCurrentForFeeEstimation() EXCLUSIVE_LOCKS_REQUIRED(cs_main)
432432
* and instead just erase from the mempool as needed.
433433
*/
434434

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

11471150
void CChainState::InitCoinsDB(
@@ -2485,7 +2488,7 @@ bool CChainState::FlushStateToDisk(
24852488
{
24862489
bool fFlushForPrune = false;
24872490
bool fDoFullFlush = false;
2488-
CoinsCacheSizeState cache_state = GetCoinsCacheSizeState(&::mempool);
2491+
CoinsCacheSizeState cache_state = GetCoinsCacheSizeState(&m_mempool);
24892492
LOCK(cs_LastBlockFile);
24902493
if (fPruneMode && (fCheckForPruning || nManualPruneHeight > 0) && !fReindex) {
24912494
if (nManualPruneHeight > 0) {
@@ -2637,7 +2640,7 @@ static void AppendWarning(std::string& res, const std::string& warn)
26372640
}
26382641

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

26902692
/** Disconnect m_chain's tip.
@@ -2697,9 +2699,10 @@ void static UpdateTip(const CBlockIndex *pindexNew, const CChainParams& chainPar
26972699
* disconnectpool (note that the caller is responsible for mempool consistency
26982700
* in any case).
26992701
*/
2700-
bool CChainState::DisconnectTip(CValidationState& state, const CChainParams& chainparams, DisconnectedBlockTransactions *disconnectpool)
2702+
bool CChainState::DisconnectTip(CValidationState& state, const CChainParams& chainparams, DisconnectedBlockTransactions* disconnectpool)
27012703
{
27022704
AssertLockHeld(cs_main);
2705+
AssertLockHeld(m_mempool.cs);
27032706

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

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

2744-
UpdateTip(pindexDelete->pprev, chainparams, *m_evoDb);
2747+
UpdateTip(m_mempool, pindexDelete->pprev, chainparams, *m_evoDb);
27452748
// Let wallets know transactions went from 1-confirmed to
27462749
// 0-confirmed or conflicted:
27472750
GetMainSignals().BlockDisconnected(pblock, pindexDelete);
@@ -2803,6 +2806,9 @@ class ConnectTrace {
28032806
bool CChainState::ConnectTip(CValidationState& state, const CChainParams& chainparams, CBlockIndex* pindexNew, const std::shared_ptr<const CBlock>& pblock, ConnectTrace& connectTrace, DisconnectedBlockTransactions &disconnectpool)
28042807
{
28052808
boost::posix_time::ptime start = boost::posix_time::microsec_clock::local_time();
2809+
AssertLockHeld(cs_main);
2810+
AssertLockHeld(m_mempool.cs);
2811+
28062812
assert(pindexNew->pprev == m_chain.Tip());
28072813
// Read block from disk.
28082814
int64_t nTime1 = GetTimeMicros();
@@ -2846,11 +2852,11 @@ bool CChainState::ConnectTip(CValidationState& state, const CChainParams& chainp
28462852
int64_t nTime5 = GetTimeMicros(); nTimeChainState += nTime5 - nTime4;
28472853
LogPrint(BCLog::BENCHMARK, " - Writing chainstate: %.2fms [%.2fs (%.2fms/blk)]\n", (nTime5 - nTime4) * MILLI, nTimeChainState * MICRO, nTimeChainState * MILLI / nBlocksTotal);
28482854
// Remove conflicting transactions from the mempool.;
2849-
mempool.removeForBlock(blockConnecting.vtx, pindexNew->nHeight);
2855+
m_mempool.removeForBlock(blockConnecting.vtx, pindexNew->nHeight);
28502856
disconnectpool.removeForBlock(blockConnecting.vtx);
28512857
// Update m_chain & related variables.
28522858
m_chain.SetTip(pindexNew);
2853-
UpdateTip(pindexNew, chainparams, *m_evoDb);
2859+
UpdateTip(m_mempool, pindexNew, chainparams, *m_evoDb);
28542860

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

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

29642971
// If we're unable to disconnect a block during normal operation,
29652972
// then that is a failure of our local system -- we should abort
@@ -3003,7 +3010,7 @@ bool CChainState::ActivateBestChainStep(CValidationState& state, const CChainPar
30033010
// A system error occurred (disk space, database error, ...).
30043011
// Make the mempool consistent with the current tip, just in case
30053012
// any observers try to use it before shutdown.
3006-
UpdateMempoolForReorg(disconnectpool, false);
3013+
UpdateMempoolForReorg(m_mempool, disconnectpool, false);
30073014
return false;
30083015
}
30093016
} else {
@@ -3020,9 +3027,9 @@ bool CChainState::ActivateBestChainStep(CValidationState& state, const CChainPar
30203027
if (fBlocksDisconnected) {
30213028
// If any blocks were disconnected, disconnectpool may be non empty. Add
30223029
// any disconnected transactions back to the mempool.
3023-
UpdateMempoolForReorg(disconnectpool, true);
3030+
UpdateMempoolForReorg(m_mempool, disconnectpool, true);
30243031
}
3025-
mempool.check(&CoinsTip());
3032+
m_mempool.check(&CoinsTip());
30263033

30273034
// Callbacks/notifications for a new best chain.
30283035
if (fInvalidFound)
@@ -3092,7 +3099,8 @@ bool CChainState::ActivateBestChain(CValidationState &state, const CChainParams&
30923099
LimitValidationInterfaceQueue();
30933100

30943101
{
3095-
LOCK2(cs_main, ::mempool.cs); // Lock transaction pool for at least as long as it takes for connectTrace to be consumed
3102+
LOCK(cs_main);
3103+
LOCK(m_mempool.cs); // Lock transaction pool for at least as long as it takes for connectTrace to be consumed
30963104
CBlockIndex* starting_tip = m_chain.Tip();
30973105
bool blocks_connected = false;
30983106
do {
@@ -3254,7 +3262,7 @@ bool CChainState::InvalidateBlock(CValidationState& state, const CChainParams& c
32543262
LimitValidationInterfaceQueue();
32553263

32563264
LOCK(cs_main);
3257-
LOCK(::mempool.cs); // Lock for as long as disconnectpool is in scope to make sure UpdateMempoolForReorg is called after DisconnectTip without unlocking in between
3265+
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
32583266
if (!m_chain.Contains(pindex)) break;
32593267
pindex_was_in_chain = true;
32603268
CBlockIndex *invalid_walk_tip = m_chain.Tip();
@@ -3274,7 +3282,7 @@ bool CChainState::InvalidateBlock(CValidationState& state, const CChainParams& c
32743282
// transactions back to the mempool if disconnecting was successful,
32753283
// and we're not doing a very deep invalidation (in which case
32763284
// keeping the mempool up to date is probably futile anyway).
3277-
UpdateMempoolForReorg(disconnectpool, /* fAddToMempool = */ (++disconnected <= 10) && ret);
3285+
UpdateMempoolForReorg(m_mempool, disconnectpool, /* fAddToMempool = */ (++disconnected <= 10) && ret);
32783286
if (!ret) return false;
32793287
assert(invalid_walk_tip->pprev == m_chain.Tip());
32803288

@@ -3410,7 +3418,7 @@ bool CChainState::MarkConflictingBlock(CValidationState& state, const CChainPara
34103418
}
34113419

34123420
{
3413-
LOCK(::mempool.cs); // Lock for as long as disconnectpool is in scope to make sure UpdateMempoolForReorg is called after DisconnectTip without unlocking in between
3421+
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
34143422
DisconnectedBlockTransactions disconnectpool;
34153423
while (m_chain.Contains(pindex)) {
34163424
const CBlockIndex* pindexOldTip = m_chain.Tip();
@@ -3420,7 +3428,7 @@ bool CChainState::MarkConflictingBlock(CValidationState& state, const CChainPara
34203428
if (!DisconnectTip(state, chainparams, &disconnectpool)) {
34213429
// It's probably hopeless to try to make the mempool consistent
34223430
// here if DisconnectTip failed, but we can try.
3423-
UpdateMempoolForReorg(disconnectpool, false);
3431+
UpdateMempoolForReorg(m_mempool, disconnectpool, false);
34243432
return false;
34253433
}
34263434
if (pindexOldTip == pindexBestHeader) {
@@ -3442,8 +3450,8 @@ bool CChainState::MarkConflictingBlock(CValidationState& state, const CChainPara
34423450

34433451
// DisconnectTip will add transactions to disconnectpool; try to add these
34443452
// back to the mempool.
3445-
UpdateMempoolForReorg(disconnectpool, true);
3446-
} // ::mempool.cs
3453+
UpdateMempoolForReorg(m_mempool, disconnectpool, true);
3454+
} // m_mempool.cs
34473455

34483456
// The resulting new best tip may not be in setBlockIndexCandidates anymore, so
34493457
// add it again.
@@ -5529,6 +5537,7 @@ CChainState& ChainstateManager::InitializeChainstate(std::unique_ptr<llmq::CChai
55295537
std::unique_ptr<llmq::CInstantSendManager>& isman,
55305538
std::unique_ptr<llmq::CQuorumBlockProcessor>& quorum_block_processor,
55315539
std::unique_ptr<CEvoDB>& evoDb,
5540+
CTxMemPool& mempool,
55325541
const uint256& snapshot_blockhash)
55335542
{
55345543
bool is_snapshot = !snapshot_blockhash.IsNull();
@@ -5539,7 +5548,7 @@ CChainState& ChainstateManager::InitializeChainstate(std::unique_ptr<llmq::CChai
55395548
throw std::logic_error("should not be overwriting a chainstate");
55405549
}
55415550

5542-
to_modify.reset(new CChainState(m_blockman, clhandler, isman, quorum_block_processor, evoDb, snapshot_blockhash));
5551+
to_modify.reset(new CChainState(m_blockman, clhandler, isman, quorum_block_processor, evoDb, mempool, snapshot_blockhash));
55435552

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

0 commit comments

Comments
 (0)