Skip to content

Commit 8e8d6eb

Browse files
committed
refactor: remove dependency of evo/deterministicmns on llmq/utils and llmq/commitment
1 parent a20e1a0 commit 8e8d6eb

File tree

8 files changed

+349
-361
lines changed

8 files changed

+349
-361
lines changed

src/evo/deterministicmns.cpp

Lines changed: 0 additions & 334 deletions
Large diffs are not rendered by default.

src/evo/deterministicmns.h

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,6 @@ class TxValidationState;
3434

3535
extern RecursiveMutex cs_main;
3636

37-
namespace llmq {
38-
class CFinalCommitment;
39-
class CQuorumSnapshotManager;
40-
} // namespace llmq
41-
4237
class CDeterministicMN
4338
{
4439
private:
@@ -569,13 +564,6 @@ class CDeterministicMNManager
569564

570565
void UpdatedBlockTip(gsl::not_null<const CBlockIndex*> pindex) EXCLUSIVE_LOCKS_REQUIRED(!cs);
571566

572-
// the returned list will not contain the correct block hash (we can't know it yet as the coinbase TX is not updated yet)
573-
bool BuildNewListFromBlock(const CBlock& block, gsl::not_null<const CBlockIndex*> pindexPrev,
574-
BlockValidationState& state, const CCoinsViewCache& view, CDeterministicMNList& mnListRet,
575-
llmq::CQuorumSnapshotManager& qsnapman, bool debugLogs) EXCLUSIVE_LOCKS_REQUIRED(!cs);
576-
void HandleQuorumCommitment(const llmq::CFinalCommitment& qc, gsl::not_null<const CBlockIndex*> pQuorumBaseBlockIndex,
577-
CDeterministicMNList& mnList, llmq::CQuorumSnapshotManager& qsnapman, bool debugLogs);
578-
579567
CDeterministicMNList GetListForBlock(gsl::not_null<const CBlockIndex*> pindex) EXCLUSIVE_LOCKS_REQUIRED(!cs) {
580568
LOCK(cs);
581569
return GetListForBlockInternal(pindex);

src/evo/specialtxman.cpp

Lines changed: 337 additions & 2 deletions
Large diffs are not rendered by default.

src/evo/specialtxman.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
#include <sync.h>
99
#include <threadsafety.h>
10-
10+
#include <gsl/pointers.h>
1111
#include <optional>
1212

1313
class BlockValidationState;
@@ -16,6 +16,7 @@ class CBlockIndex;
1616
class CCbTx;
1717
class CCoinsViewCache;
1818
class CCreditPoolManager;
19+
class CDeterministicMNList;
1920
class CDeterministicMNManager;
2021
class CTransaction;
2122
class ChainstateManager;
@@ -71,6 +72,11 @@ class CSpecialTxProcessor
7172
bool UndoSpecialTxsInBlock(const CBlock& block, const CBlockIndex* pindex, std::optional<MNListUpdates>& updatesRet)
7273
EXCLUSIVE_LOCKS_REQUIRED(::cs_main);
7374

75+
76+
// the returned list will not contain the correct block hash (we can't know it yet as the coinbase TX is not updated yet)
77+
bool BuildNewListFromBlock(const CBlock& block, gsl::not_null<const CBlockIndex*> pindexPrev,
78+
const CCoinsViewCache& view, bool debugLogs,
79+
BlockValidationState& state, CDeterministicMNList& mnListRet) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
7480
private:
7581
bool CheckCreditPoolDiffForBlock(const CBlock& block, const CBlockIndex* pindex, const CCbTx& cbTx,
7682
BlockValidationState& state) EXCLUSIVE_LOCKS_REQUIRED(::cs_main);

src/node/miner.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
#include <evo/deterministicmns.h>
3232
#include <evo/mnhftx.h>
3333
#include <evo/simplifiedmns.h>
34+
#include <evo/specialtxman.h>
3435
#include <governance/governance.h>
3536
#include <llmq/blockprocessor.h>
3637
#include <llmq/chainlocks.h>
@@ -73,12 +74,10 @@ BlockAssembler::BlockAssembler(CChainState& chainstate, const NodeContext& node,
7374
m_cpoolman(*Assert(node.cpoolman)),
7475
m_chain_helper(chainstate.ChainHelper()),
7576
m_chainstate(chainstate),
76-
m_dmnman(*Assert(node.dmnman)),
7777
m_evoDb(*Assert(node.evodb)),
7878
m_mnhfman(*Assert(node.mnhf_manager)),
7979
m_clhandler(*Assert(Assert(node.llmq_ctx)->clhandler)),
8080
m_isman(*Assert(Assert(node.llmq_ctx)->isman)),
81-
m_qsnapman(*Assert(Assert(node.llmq_ctx)->qsnapman)),
8281
chainparams(params),
8382
m_mempool(mempool),
8483
m_quorum_block_processor(*Assert(Assert(node.llmq_ctx)->quorum_block_processor)),
@@ -289,7 +288,7 @@ std::unique_ptr<CBlockTemplate> BlockAssembler::CreateNewBlock(const CScript& sc
289288

290289
BlockValidationState state;
291290
CDeterministicMNList mn_list;
292-
if (!m_dmnman.BuildNewListFromBlock(*pblock, pindexPrev, state, m_chainstate.CoinsTip(), mn_list, m_qsnapman, true)) {
291+
if (!m_chain_helper.special_tx->BuildNewListFromBlock(*pblock, pindexPrev, m_chainstate.CoinsTip(), true, state, mn_list)) {
293292
throw std::runtime_error(strprintf("%s: BuildNewListFromBlock failed: %s", __func__, state.ToString()));
294293
}
295294
if (!CalcCbTxMerkleRootMNList(cbTx.merkleRootMNList, CSimplifiedMNList(mn_list), state)) {

src/node/miner.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ class CChainParams;
2424
class CChainstateHelper;
2525
class CConnman;
2626
class CCreditPoolManager;
27-
class CDeterministicMNManager;
2827
class CEvoDB;
2928
class CMNHFManager;
3029
class CScript;
@@ -36,7 +35,6 @@ class CChainLocksHandler;
3635
class CInstantSendManager;
3736
class CQuorumBlockProcessor;
3837
class CQuorumManager;
39-
class CQuorumSnapshotManager;
4038
} // namespace llmq
4139

4240
namespace node {
@@ -172,12 +170,10 @@ class BlockAssembler
172170
CCreditPoolManager& m_cpoolman;
173171
CChainstateHelper& m_chain_helper;
174172
CChainState& m_chainstate;
175-
CDeterministicMNManager& m_dmnman;
176173
CEvoDB& m_evoDb;
177174
CMNHFManager& m_mnhfman;
178175
llmq::CChainLocksHandler& m_clhandler;
179176
llmq::CInstantSendManager& m_isman;
180-
llmq::CQuorumSnapshotManager& m_qsnapman;
181177
const CChainParams& chainparams;
182178
const CTxMemPool* const m_mempool;
183179
const llmq::CQuorumBlockProcessor& m_quorum_block_processor;

src/test/util/setup_common.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,14 @@
4848
#include <bls/bls.h>
4949
#include <coinjoin/context.h>
5050
#include <evo/cbtx.h>
51+
#include <evo/chainhelper.h>
5152
#include <evo/creditpool.h>
5253
#include <evo/deterministicmns.h>
5354
#include <evo/evodb.h>
5455
#include <evo/mnhftx.h>
5556
#include <evo/simplifiedmns.h>
5657
#include <evo/specialtx.h>
58+
#include <evo/specialtxman.h>
5759
#include <flat-database.h>
5860
#include <governance/governance.h>
5961
#include <llmq/context.h>
@@ -503,7 +505,7 @@ CBlock TestChainSetup::CreateBlock(
503505
Assert(cbTx.has_value());
504506
BlockValidationState state;
505507
CDeterministicMNList mn_list;
506-
if (!m_node.dmnman->BuildNewListFromBlock(block, chainstate.m_chain.Tip(), state, chainstate.CoinsTip(), mn_list, *m_node.llmq_ctx->qsnapman, true)) {
508+
if (!chainstate.ChainHelper().special_tx->BuildNewListFromBlock(block, chainstate.m_chain.Tip(), chainstate.CoinsTip(), true, state, mn_list)) {
507509
Assert(false);
508510
}
509511
if (!CalcCbTxMerkleRootMNList(cbTx->merkleRootMNList, CSimplifiedMNList(mn_list), state)) {

test/lint/lint-circular-dependencies.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,6 @@
3838
"evo/chainhelper -> evo/specialtxman -> validation -> evo/chainhelper",
3939
"evo/deterministicmns -> index/txindex -> validation -> evo/deterministicmns",
4040
"evo/deterministicmns -> index/txindex -> validation -> txmempool -> evo/deterministicmns",
41-
"evo/deterministicmns -> llmq/commitment -> evo/deterministicmns",
42-
"evo/deterministicmns -> llmq/utils -> evo/deterministicmns",
43-
"evo/deterministicmns -> llmq/utils -> llmq/snapshot -> evo/simplifiedmns -> evo/deterministicmns",
44-
"evo/deterministicmns -> llmq/utils -> net -> evo/deterministicmns",
4541
"evo/deterministicmns -> validationinterface -> evo/deterministicmns",
4642
"evo/deterministicmns -> validationinterface -> governance/vote -> evo/deterministicmns",
4743
"evo/netinfo -> evo/providertx -> evo/netinfo",

0 commit comments

Comments
 (0)