Skip to content

Commit 96d0ce2

Browse files
authored
refactor: reduce usage of chainstate globals in Dash-specific logic (#5531)
Co-authored-by: Kittywhiskers Van Gogh <[email protected]>
1 parent 3443630 commit 96d0ce2

23 files changed

+209
-160
lines changed

src/coinjoin/server.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ void CCoinJoinServer::CommitFinalTransaction()
322322
TRY_LOCK(cs_main, lockMain);
323323
TxValidationState validationState;
324324
mempool.PrioritiseTransaction(hashTx, 0.1 * COIN);
325-
if (!lockMain || !AcceptToMemoryPool(::ChainstateActive(), mempool, validationState, finalTransaction, false /* bypass_limits */, DEFAULT_MAX_RAW_TX_FEE /* nAbsurdFee */)) {
325+
if (!lockMain || !AcceptToMemoryPool(m_chainstate, mempool, validationState, finalTransaction, false /* bypass_limits */, DEFAULT_MAX_RAW_TX_FEE /* nAbsurdFee */)) {
326326
LogPrint(BCLog::COINJOIN, "CCoinJoinServer::CommitFinalTransaction -- AcceptToMemoryPool() error: Transaction not valid\n");
327327
WITH_LOCK(cs_coinjoin, SetNull());
328328
// not much we can do in this case, just notify clients
@@ -455,7 +455,7 @@ void CCoinJoinServer::ConsumeCollateral(const CTransactionRef& txref) const
455455
{
456456
LOCK(cs_main);
457457
TxValidationState validationState;
458-
if (!AcceptToMemoryPool(::ChainstateActive(), mempool, validationState, txref, false /* bypass_limits */, 0 /* nAbsurdFee */)) {
458+
if (!AcceptToMemoryPool(m_chainstate, mempool, validationState, txref, false /* bypass_limits */, 0 /* nAbsurdFee */)) {
459459
LogPrint(BCLog::COINJOIN, "%s -- AcceptToMemoryPool failed\n", __func__);
460460
} else {
461461
connman.RelayTransaction(*txref);

src/coinjoin/server.h

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include <coinjoin/coinjoin.h>
99
#include <net.h>
1010

11+
class CChainState;
1112
class CCoinJoinServer;
1213
class CTxMemPool;
1314
class PeerManager;
@@ -22,8 +23,9 @@ extern std::unique_ptr<CCoinJoinServer> coinJoinServer;
2223
class CCoinJoinServer : public CCoinJoinBaseSession, public CCoinJoinBaseManager
2324
{
2425
private:
25-
CTxMemPool& mempool;
26+
CChainState& m_chainstate;
2627
CConnman& connman;
28+
CTxMemPool& mempool;
2729
const CMasternodeSync& m_mn_sync;
2830

2931
// Mixing uses collateral transactions to trust parties entering the pool
@@ -79,9 +81,10 @@ class CCoinJoinServer : public CCoinJoinBaseSession, public CCoinJoinBaseManager
7981
void SetNull() EXCLUSIVE_LOCKS_REQUIRED(cs_coinjoin);
8082

8183
public:
82-
explicit CCoinJoinServer(CTxMemPool& mempool, CConnman& _connman, const CMasternodeSync& mn_sync) :
83-
mempool(mempool),
84+
explicit CCoinJoinServer(CChainState& chainstate, CConnman& _connman, CTxMemPool& mempool, const CMasternodeSync& mn_sync) :
85+
m_chainstate(chainstate),
8486
connman(_connman),
87+
mempool(mempool),
8588
m_mn_sync(mn_sync),
8689
vecSessionCollaterals(),
8790
fUnitTest(false)

src/evo/deterministicmns.cpp

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1192,7 +1192,7 @@ bool CDeterministicMNManager::MigrateDBIfNeeded()
11921192

11931193
LogPrintf("CDeterministicMNManager::%s -- upgrading DB to migrate MN type\n", __func__);
11941194

1195-
if (::ChainActive().Tip() == nullptr) {
1195+
if (m_chainstate.m_chain.Tip() == nullptr) {
11961196
// should have no records
11971197
LogPrintf("CDeterministicMNManager::%s -- Chain empty. evoDB:%d.\n", __func__, m_evoDb.IsEmpty());
11981198
return m_evoDb.IsEmpty();
@@ -1203,7 +1203,7 @@ bool CDeterministicMNManager::MigrateDBIfNeeded()
12031203
return true;
12041204
}
12051205

1206-
if (::ChainActive().Tip()->pprev != nullptr && llmq::utils::IsV19Active(::ChainActive().Tip()->pprev)) {
1206+
if (m_chainstate.m_chain.Tip()->pprev != nullptr && llmq::utils::IsV19Active(m_chainstate.m_chain.Tip()->pprev)) {
12071207
// too late
12081208
LogPrintf("CDeterministicMNManager::%s -- migration is not possible\n", __func__);
12091209
return false;
@@ -1212,25 +1212,25 @@ bool CDeterministicMNManager::MigrateDBIfNeeded()
12121212
// Removing the old EVODB_BEST_BLOCK value early results in older version to crash immediately, even if the upgrade
12131213
// process is cancelled in-between. But if the new version sees that the old EVODB_BEST_BLOCK is already removed,
12141214
// then we must assume that the upgrade process was already running before but was interrupted.
1215-
if (::ChainActive().Height() > 1 && !m_evoDb.GetRawDB().Exists(DB_OLD_BEST_BLOCK)) {
1215+
if (m_chainstate.m_chain.Height() > 1 && !m_evoDb.GetRawDB().Exists(DB_OLD_BEST_BLOCK)) {
12161216
LogPrintf("CDeterministicMNManager::%s -- previous migration attempt failed.\n", __func__);
12171217
return false;
12181218
}
12191219
m_evoDb.GetRawDB().Erase(DB_OLD_BEST_BLOCK);
12201220

1221-
if (::ChainActive().Height() < Params().GetConsensus().DIP0003Height) {
1221+
if (m_chainstate.m_chain.Height() < Params().GetConsensus().DIP0003Height) {
12221222
// not reached DIP3 height yet, so no upgrade needed
12231223
LogPrintf("CDeterministicMNManager::%s -- migration not needed. dip3 not reached\n", __func__);
12241224
auto dbTx = m_evoDb.BeginTransaction();
1225-
m_evoDb.WriteBestBlock(::ChainActive().Tip()->GetBlockHash());
1225+
m_evoDb.WriteBestBlock(m_chainstate.m_chain.Tip()->GetBlockHash());
12261226
dbTx->Commit();
12271227
return true;
12281228
}
12291229

12301230
CDBBatch batch(m_evoDb.GetRawDB());
12311231

1232-
for (const auto nHeight : irange::range(Params().GetConsensus().DIP0003Height, ::ChainActive().Height() + 1)) {
1233-
auto pindex = ::ChainActive()[nHeight];
1232+
for (const auto nHeight : irange::range(Params().GetConsensus().DIP0003Height, m_chainstate.m_chain.Height() + 1)) {
1233+
auto pindex = m_chainstate.m_chain[nHeight];
12341234
// Unserialise CDeterministicMNListDiff using MN_OLD_FORMAT and set it's type to the default value TYPE_REGULAR_MASTERNODE
12351235
// It will be later written with format MN_CURRENT_FORMAT which includes the type field and MN state bls version.
12361236
CDataStream diff_data(SER_DISK, CLIENT_VERSION);
@@ -1258,7 +1258,7 @@ bool CDeterministicMNManager::MigrateDBIfNeeded()
12581258

12591259
// Writing EVODB_BEST_BLOCK (which is b_b4 now) marks the DB as upgraded
12601260
auto dbTx = m_evoDb.BeginTransaction();
1261-
m_evoDb.WriteBestBlock(::ChainActive().Tip()->GetBlockHash());
1261+
m_evoDb.WriteBestBlock(m_chainstate.m_chain.Tip()->GetBlockHash());
12621262
dbTx->Commit();
12631263

12641264
LogPrintf("CDeterministicMNManager::%s -- done migrating\n", __func__);
@@ -1291,7 +1291,7 @@ bool CDeterministicMNManager::MigrateDBIfNeeded2()
12911291

12921292
LogPrintf("CDeterministicMNManager::%s -- upgrading DB to migrate MN state bls version\n", __func__);
12931293

1294-
if (::ChainActive().Tip() == nullptr) {
1294+
if (m_chainstate.m_chain.Tip() == nullptr) {
12951295
// should have no records
12961296
LogPrintf("CDeterministicMNManager::%s -- Chain empty. evoDB:%d.\n", __func__, m_evoDb.IsEmpty());
12971297
return m_evoDb.IsEmpty();
@@ -1302,7 +1302,7 @@ bool CDeterministicMNManager::MigrateDBIfNeeded2()
13021302
return true;
13031303
}
13041304

1305-
if (::ChainActive().Tip()->pprev != nullptr && llmq::utils::IsV19Active(::ChainActive().Tip()->pprev)) {
1305+
if (m_chainstate.m_chain.Tip()->pprev != nullptr && llmq::utils::IsV19Active(m_chainstate.m_chain.Tip()->pprev)) {
13061306
// too late
13071307
LogPrintf("CDeterministicMNManager::%s -- migration is not possible\n", __func__);
13081308
return false;
@@ -1311,25 +1311,25 @@ bool CDeterministicMNManager::MigrateDBIfNeeded2()
13111311
// Removing the old EVODB_BEST_BLOCK value early results in older version to crash immediately, even if the upgrade
13121312
// process is cancelled in-between. But if the new version sees that the old EVODB_BEST_BLOCK is already removed,
13131313
// then we must assume that the upgrade process was already running before but was interrupted.
1314-
if (::ChainActive().Height() > 1 && !m_evoDb.GetRawDB().Exists(DB_OLD_BEST_BLOCK)) {
1314+
if (m_chainstate.m_chain.Height() > 1 && !m_evoDb.GetRawDB().Exists(DB_OLD_BEST_BLOCK)) {
13151315
LogPrintf("CDeterministicMNManager::%s -- previous migration attempt failed.\n", __func__);
13161316
return false;
13171317
}
13181318
m_evoDb.GetRawDB().Erase(DB_OLD_BEST_BLOCK);
13191319

1320-
if (::ChainActive().Height() < Params().GetConsensus().DIP0003Height) {
1320+
if (m_chainstate.m_chain.Height() < Params().GetConsensus().DIP0003Height) {
13211321
// not reached DIP3 height yet, so no upgrade needed
13221322
LogPrintf("CDeterministicMNManager::%s -- migration not needed. dip3 not reached\n", __func__);
13231323
auto dbTx = m_evoDb.BeginTransaction();
1324-
m_evoDb.WriteBestBlock(::ChainActive().Tip()->GetBlockHash());
1324+
m_evoDb.WriteBestBlock(m_chainstate.m_chain.Tip()->GetBlockHash());
13251325
dbTx->Commit();
13261326
return true;
13271327
}
13281328

13291329
CDBBatch batch(m_evoDb.GetRawDB());
13301330

1331-
for (const auto nHeight : irange::range(Params().GetConsensus().DIP0003Height, ::ChainActive().Height() + 1)) {
1332-
auto pindex = ::ChainActive()[nHeight];
1331+
for (const auto nHeight : irange::range(Params().GetConsensus().DIP0003Height, m_chainstate.m_chain.Height() + 1)) {
1332+
auto pindex = m_chainstate.m_chain[nHeight];
13331333
// Unserialise CDeterministicMNListDiff using MN_TYPE_FORMAT and set MN state bls version to LEGACY_BLS_VERSION.
13341334
// It will be later written with format MN_CURRENT_FORMAT which includes the type field.
13351335
CDataStream diff_data(SER_DISK, CLIENT_VERSION);
@@ -1357,7 +1357,7 @@ bool CDeterministicMNManager::MigrateDBIfNeeded2()
13571357

13581358
// Writing EVODB_BEST_BLOCK (which is b_b4 now) marks the DB as upgraded
13591359
auto dbTx = m_evoDb.BeginTransaction();
1360-
m_evoDb.WriteBestBlock(::ChainActive().Tip()->GetBlockHash());
1360+
m_evoDb.WriteBestBlock(m_chainstate.m_chain.Tip()->GetBlockHash());
13611361
dbTx->Commit();
13621362

13631363
LogPrintf("CDeterministicMNManager::%s -- done migrating\n", __func__);

src/evo/deterministicmns.h

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,10 @@
2424
#include <unordered_map>
2525
#include <utility>
2626

27-
class CConnman;
2827
class CBlock;
2928
class CBlockIndex;
29+
class CChainState;
30+
class CConnman;
3031
class TxValidationState;
3132

3233
extern RecursiveMutex cs_main;
@@ -583,17 +584,18 @@ class CDeterministicMNManager
583584
// Main thread has indicated we should perform cleanup up to this height
584585
std::atomic<int> to_cleanup {0};
585586

586-
CEvoDB& m_evoDb;
587+
CChainState& m_chainstate;
587588
CConnman& connman;
589+
CEvoDB& m_evoDb;
588590

589591
std::unordered_map<uint256, CDeterministicMNList, StaticSaltedHasher> mnListsCache GUARDED_BY(cs);
590592
std::unordered_map<uint256, CDeterministicMNListDiff, StaticSaltedHasher> mnListDiffsCache GUARDED_BY(cs);
591593
const CBlockIndex* tipIndex GUARDED_BY(cs) {nullptr};
592594
const CBlockIndex* m_initial_snapshot_index GUARDED_BY(cs) {nullptr};
593595

594596
public:
595-
explicit CDeterministicMNManager(CEvoDB& evoDb, CConnman& _connman) :
596-
m_evoDb(evoDb), connman(_connman) {}
597+
explicit CDeterministicMNManager(CChainState& chainstate, CConnman& _connman, CEvoDB& evoDb) :
598+
m_chainstate(chainstate), connman(_connman), m_evoDb(evoDb) {}
597599
~CDeterministicMNManager() = default;
598600

599601
bool ProcessBlock(const CBlock& block, const CBlockIndex* pindex, BlockValidationState& state,

src/init.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1937,12 +1937,13 @@ bool AppInitMain(const CoreContext& context, NodeContext& node, interfaces::Bloc
19371937

19381938
// Same logic as above with pblocktree
19391939
deterministicMNManager.reset();
1940-
deterministicMNManager.reset(new CDeterministicMNManager(*node.evodb, *node.connman));
1940+
deterministicMNManager.reset(new CDeterministicMNManager(chainman.ActiveChainstate(), *node.connman, *node.evodb));
1941+
creditPoolManager.reset();
19411942
creditPoolManager.reset(new CCreditPoolManager(*node.evodb));
19421943
llmq::quorumSnapshotManager.reset();
19431944
llmq::quorumSnapshotManager.reset(new llmq::CQuorumSnapshotManager(*node.evodb));
19441945
node.llmq_ctx.reset();
1945-
node.llmq_ctx.reset(new LLMQContext(*node.evodb, *node.mempool, *node.connman, *::sporkManager, node.peerman, false, fReset || fReindexChainState));
1946+
node.llmq_ctx.reset(new LLMQContext(chainman.ActiveChainstate(), *node.connman, *node.evodb, *::sporkManager, *node.mempool, node.peerman, false, fReset || fReindexChainState));
19461947

19471948
if (fReset) {
19481949
pblocktree->WriteReindexing(true);
@@ -2248,7 +2249,7 @@ bool AppInitMain(const CoreContext& context, NodeContext& node, interfaces::Bloc
22482249

22492250
// ********************************************************* Step 10a: Setup CoinJoin
22502251

2251-
::coinJoinServer = std::make_unique<CCoinJoinServer>(*node.mempool, *node.connman, *::masternodeSync);
2252+
::coinJoinServer = std::make_unique<CCoinJoinServer>(chainman.ActiveChainstate(), *node.connman, *node.mempool, *::masternodeSync);
22522253
#ifdef ENABLE_WALLET
22532254
if (!ignores_incoming_txs) {
22542255
::coinJoinClientQueueManager = std::make_unique<CCoinJoinClientQueueManager>(*node.connman, *::masternodeSync);

src/llmq/blockprocessor.cpp

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ static const std::string DB_MINED_COMMITMENT_BY_INVERSED_HEIGHT_Q_INDEXED = "q_m
4646

4747
static const std::string DB_BEST_BLOCK_UPGRADE = "q_bbu2";
4848

49-
CQuorumBlockProcessor::CQuorumBlockProcessor(CEvoDB& evoDb, CConnman& _connman, const std::unique_ptr<PeerManager>& peerman) :
50-
m_evoDb(evoDb), connman(_connman), m_peerman(peerman)
49+
CQuorumBlockProcessor::CQuorumBlockProcessor(CChainState& chainstate, CConnman& _connman, CEvoDB& evoDb, const std::unique_ptr<PeerManager>& peerman) :
50+
m_chainstate(chainstate), connman(_connman), m_evoDb(evoDb), m_peerman(peerman)
5151
{
5252
utils::InitQuorumsCache(mapHasMinedCommitmentCache);
5353
}
@@ -82,15 +82,15 @@ void CQuorumBlockProcessor::ProcessMessage(const CNode& peer, std::string_view m
8282
const CBlockIndex* pQuorumBaseBlockIndex;
8383
{
8484
LOCK(cs_main);
85-
pQuorumBaseBlockIndex = g_chainman.m_blockman.LookupBlockIndex(qc.quorumHash);
85+
pQuorumBaseBlockIndex = m_chainstate.m_blockman.LookupBlockIndex(qc.quorumHash);
8686
if (pQuorumBaseBlockIndex == nullptr) {
8787
LogPrint(BCLog::LLMQ, "CQuorumBlockProcessor::%s -- unknown block %s in commitment, peer=%d\n", __func__,
8888
qc.quorumHash.ToString(), peer.GetId());
8989
// can't really punish the node here, as we might simply be the one that is on the wrong chain or not
9090
// fully synced
9191
return;
9292
}
93-
if (::ChainActive().Tip()->GetAncestor(pQuorumBaseBlockIndex->nHeight) != pQuorumBaseBlockIndex) {
93+
if (m_chainstate.m_chain.Tip()->GetAncestor(pQuorumBaseBlockIndex->nHeight) != pQuorumBaseBlockIndex) {
9494
LogPrint(BCLog::LLMQ, "CQuorumBlockProcessor::%s -- block %s not in active chain, peer=%d\n", __func__,
9595
qc.quorumHash.ToString(), peer.GetId());
9696
// same, can't punish
@@ -103,7 +103,7 @@ void CQuorumBlockProcessor::ProcessMessage(const CNode& peer, std::string_view m
103103
m_peerman->Misbehaving(peer.GetId(), 100);
104104
return;
105105
}
106-
if (pQuorumBaseBlockIndex->nHeight < (::ChainActive().Height() - llmq_params_opt->dkgInterval)) {
106+
if (pQuorumBaseBlockIndex->nHeight < (m_chainstate.m_chain.Height() - llmq_params_opt->dkgInterval)) {
107107
LogPrint(BCLog::LLMQ, "CQuorumBlockProcessor::%s -- block %s is too old, peer=%d\n", __func__,
108108
qc.quorumHash.ToString(), peer.GetId());
109109
// TODO: enable punishment in some future version when all/most nodes are running with this fix
@@ -171,7 +171,7 @@ bool CQuorumBlockProcessor::ProcessBlock(const CBlock& block, const CBlockIndex*
171171
// Note: must only check quorums that were enabled at the _previous_ block height to match mining logic
172172
for (const Consensus::LLMQParams& params : utils::GetEnabledQuorumParams(pindex->pprev)) {
173173
// skip these checks when replaying blocks after the crash
174-
if (::ChainActive().Tip() == nullptr) {
174+
if (m_chainstate.m_chain.Tip() == nullptr) {
175175
break;
176176
}
177177

@@ -234,7 +234,7 @@ bool CQuorumBlockProcessor::ProcessCommitment(int nHeight, const uint256& blockH
234234
nHeight, ToUnderlying(qc.llmqType), qc.quorumIndex, quorumHash.ToString(), qc.CountSigners(), qc.CountValidMembers(), qc.quorumPublicKey.ToString(), fJustCheck);
235235

236236
// skip `bad-qc-block` checks below when replaying blocks after the crash
237-
if (::ChainActive().Tip() == nullptr) {
237+
if (m_chainstate.m_chain.Tip() == nullptr) {
238238
quorumHash = qc.quorumHash;
239239
}
240240

@@ -268,7 +268,7 @@ bool CQuorumBlockProcessor::ProcessCommitment(int nHeight, const uint256& blockH
268268
return state.Invalid(BlockValidationResult::BLOCK_CONSENSUS, "bad-qc-height");
269269
}
270270

271-
const auto* pQuorumBaseBlockIndex = g_chainman.m_blockman.LookupBlockIndex(qc.quorumHash);
271+
const auto* pQuorumBaseBlockIndex = m_chainstate.m_blockman.LookupBlockIndex(qc.quorumHash);
272272

273273
if (!qc.Verify(pQuorumBaseBlockIndex, fBLSChecks)) {
274274
LogPrint(BCLog::LLMQ, "CQuorumBlockProcessor::%s height=%d, type=%d, quorumIndex=%d, quorumHash=%s, signers=%s, validMembers=%d, quorumPublicKey=%s qc verify failed.\n", __func__,
@@ -358,20 +358,20 @@ bool CQuorumBlockProcessor::UpgradeDB()
358358
{
359359
LOCK(cs_main);
360360

361-
if (::ChainActive().Tip() == nullptr) {
361+
if (m_chainstate.m_chain.Tip() == nullptr) {
362362
// should have no records
363363
return m_evoDb.IsEmpty();
364364
}
365365

366366
uint256 bestBlock;
367-
if (m_evoDb.GetRawDB().Read(DB_BEST_BLOCK_UPGRADE, bestBlock) && bestBlock == ::ChainActive().Tip()->GetBlockHash()) {
367+
if (m_evoDb.GetRawDB().Read(DB_BEST_BLOCK_UPGRADE, bestBlock) && bestBlock == m_chainstate.m_chain.Tip()->GetBlockHash()) {
368368
return true;
369369
}
370370

371371
LogPrintf("CQuorumBlockProcessor::%s -- Upgrading DB...\n", __func__);
372372

373-
if (::ChainActive().Height() >= Params().GetConsensus().DIP0003EnforcementHeight) {
374-
const auto* pindex = ::ChainActive()[Params().GetConsensus().DIP0003EnforcementHeight];
373+
if (m_chainstate.m_chain.Height() >= Params().GetConsensus().DIP0003EnforcementHeight) {
374+
const auto* pindex = m_chainstate.m_chain[Params().GetConsensus().DIP0003EnforcementHeight];
375375
while (pindex != nullptr) {
376376
if (fPruneMode && ((pindex->nStatus & BLOCK_HAVE_DATA) == 0)) {
377377
// Too late, we already pruned blocks we needed to reprocess commitments
@@ -390,7 +390,7 @@ bool CQuorumBlockProcessor::UpgradeDB()
390390
if (qc.IsNull()) {
391391
continue;
392392
}
393-
const auto* pQuorumBaseBlockIndex = g_chainman.m_blockman.LookupBlockIndex(qc.quorumHash);
393+
const auto* pQuorumBaseBlockIndex = m_chainstate.m_blockman.LookupBlockIndex(qc.quorumHash);
394394
m_evoDb.GetRawDB().Write(std::make_pair(DB_MINED_COMMITMENT, std::make_pair(qc.llmqType, qc.quorumHash)), std::make_pair(qc, pindex->GetBlockHash()));
395395
const auto& llmq_params_opt = GetLLMQParams(qc.llmqType);
396396
assert(llmq_params_opt.has_value());
@@ -403,7 +403,7 @@ bool CQuorumBlockProcessor::UpgradeDB()
403403

404404
m_evoDb.GetRawDB().Write(DB_BEST_BLOCK_UPGRADE, pindex->GetBlockHash());
405405

406-
pindex = ::ChainActive().Next(pindex);
406+
pindex = m_chainstate.m_chain.Next(pindex);
407407
}
408408
}
409409

@@ -479,8 +479,8 @@ size_t CQuorumBlockProcessor::GetNumCommitmentsRequired(const Consensus::LLMQPar
479479
if (!IsMiningPhase(llmqParams, nHeight)) return 0;
480480

481481
// Note: This function can be called for new blocks
482-
assert(nHeight <= ::ChainActive().Height() + 1);
483-
const auto *const pindex = ::ChainActive().Height() < nHeight ? ::ChainActive().Tip() : ::ChainActive().Tip()->GetAncestor(nHeight);
482+
assert(nHeight <= m_chainstate.m_chain.Height() + 1);
483+
const auto *const pindex = m_chainstate.m_chain.Height() < nHeight ? m_chainstate.m_chain.Tip() : m_chainstate.m_chain.Tip()->GetAncestor(nHeight);
484484

485485
bool rotation_enabled = utils::IsQuorumRotationEnabled(llmqParams, pindex);
486486
size_t quorums_num = rotation_enabled ? llmqParams.signingActiveQuorumCount : 1;
@@ -763,8 +763,8 @@ std::optional<std::vector<CFinalCommitment>> CQuorumBlockProcessor::GetMineableC
763763
}
764764

765765
// Note: This function can be called for new blocks
766-
assert(nHeight <= ::ChainActive().Height() + 1);
767-
const auto *const pindex = ::ChainActive().Height() < nHeight ? ::ChainActive().Tip() : ::ChainActive().Tip()->GetAncestor(nHeight);
766+
assert(nHeight <= m_chainstate.m_chain.Height() + 1);
767+
const auto *const pindex = m_chainstate.m_chain.Height() < nHeight ? m_chainstate.m_chain.Tip() : m_chainstate.m_chain.Tip()->GetAncestor(nHeight);
768768

769769
bool rotation_enabled = utils::IsQuorumRotationEnabled(llmqParams, pindex);
770770
bool basic_bls_enabled = utils::IsV19Active(pindex);

0 commit comments

Comments
 (0)