Skip to content

Commit fe99b59

Browse files
Merge #6736: refactor: nuke circular dependencies over validationinterface
e875c42 refactor: drop dependency net on coinjoin/coinjoin by removing unused header (Konstantin Akimov) 22af04b refactor: nuke circular dependencies over validationinterface (Konstantin Akimov) Pull request description: ## What was done? See commits ## How Has This Been Tested? By running `test/lint/lint-circular-dependencies.py` ``` - "coinjoin/coinjoin -> llmq/chainlocks -> net -> coinjoin/coinjoin", - "evo/deterministicmns -> validationinterface -> evo/deterministicmns", - "evo/deterministicmns -> validationinterface -> governance/vote -> evo/deterministicmns", - "governance/vote -> masternode/node -> validationinterface -> governance/vote", - "llmq/signing -> masternode/node -> validationinterface -> llmq/signing", ``` ## Breaking Changes N/A ## Checklist: - [x] I have performed a self-review of my own code - [x] I have commented my code, particularly in hard-to-understand areas - [x] I have added or updated relevant unit/integration/functional/e2e tests - [ ] I have made corresponding changes to the documentation - [x] I have assigned this pull request to a milestone ACKs for top commit: PastaPastaPasta: utACK e875c42; builds locally kwvg: utACK e875c42 UdjinM6: utACK e875c42 Tree-SHA512: 2ee9b9f6946ba5bd9d924eac7207e4cfd8288cc78645778ab08e5bd4eaa03765d04d67a1ad075d1cdf7e5fa8f7eaf09c5f8248d9154a60493b2424a510374a4a
2 parents c33122d + e875c42 commit fe99b59

14 files changed

+27
-36
lines changed

src/governance/governance.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ void CGovernanceManager::AddGovernanceObject(CGovernanceObject& govobj, PeerMana
358358
CheckOrphanVotes(govobj, peerman);
359359

360360
// SEND NOTIFICATION TO SCRIPT/ZMQ
361-
GetMainSignals().NotifyGovernanceObject(std::make_shared<const Governance::Object>(govobj.Object()));
361+
GetMainSignals().NotifyGovernanceObject(std::make_shared<const Governance::Object>(govobj.Object()), nHash.ToString());
362362
}
363363

364364
void CGovernanceManager::CheckAndRemove()

src/governance/object.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,8 @@ bool CGovernanceObject::ProcessVote(CMasternodeMetaMan& mn_metaman, CGovernanceM
162162
fileVotes.AddVote(vote);
163163
fDirtyCache = true;
164164
// SEND NOTIFICATION TO SCRIPT/ZMQ
165-
GetMainSignals().NotifyGovernanceVote(tip_mn_list, std::make_shared<const CGovernanceVote>(vote));
165+
GetMainSignals().NotifyGovernanceVote(std::make_shared<CDeterministicMNList>(tip_mn_list),
166+
std::make_shared<const CGovernanceVote>(vote), vote.GetHash().ToString());
166167
return true;
167168
}
168169

src/llmq/chainlocks.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -506,7 +506,7 @@ void CChainLocksHandler::EnforceBestChainLock()
506506
lastNotifyChainLockBlockIndex = currentBestChainLockBlockIndex;
507507
}
508508

509-
GetMainSignals().NotifyChainLock(currentBestChainLockBlockIndex, clsig);
509+
GetMainSignals().NotifyChainLock(currentBestChainLockBlockIndex, clsig, clsig->ToString());
510510
uiInterface.NotifyChainLock(clsig->getBlockHash().ToString(), clsig->getHeight());
511511
::g_stats_client->gauge("chainlocks.blockHeight", clsig->getHeight(), 1.0f);
512512
}

src/llmq/signing.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -644,7 +644,7 @@ void CSigningManager::ProcessRecoveredSig(const std::shared_ptr<const CRecovered
644644
peerman.PostProcessMessage(l->HandleNewRecoveredSig(*recoveredSig));
645645
}
646646

647-
GetMainSignals().NotifyRecoveredSig(recoveredSig);
647+
GetMainSignals().NotifyRecoveredSig(recoveredSig, recoveredSig->GetHash().ToString());
648648
}
649649

650650
void CSigningManager::PushReconstructedRecoveredSig(const std::shared_ptr<const llmq::CRecoveredSig>& recoveredSig)

src/net.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@
4141

4242
#include <masternode/meta.h>
4343
#include <masternode/sync.h>
44-
#include <coinjoin/coinjoin.h>
4544
#include <evo/deterministicmns.h>
4645

4746
#include <stats/client.h>

src/validationinterface.cpp

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,10 @@
77

88
#include <chain.h>
99
#include <consensus/validation.h>
10-
#include <governance/common.h>
1110
#include <logging.h>
1211
#include <primitives/block.h>
1312
#include <primitives/transaction.h>
1413
#include <scheduler.h>
15-
#include <evo/deterministicmns.h>
16-
#include <governance/vote.h>
17-
#include <llmq/clsig.h>
18-
#include <llmq/signing.h>
1914

2015
#include <future>
2116
#include <unordered_map>
@@ -279,27 +274,27 @@ void CMainSignals::NotifyTransactionLock(const CTransactionRef &tx, const std::s
279274
tx->GetHash().ToString());
280275
}
281276

282-
void CMainSignals::NotifyChainLock(const CBlockIndex* pindex, const std::shared_ptr<const llmq::CChainLockSig>& clsig) {
277+
void CMainSignals::NotifyChainLock(const CBlockIndex* pindex, const std::shared_ptr<const llmq::CChainLockSig>& clsig, const std::string& id) {
283278
auto event = [pindex, clsig, this] {
284279
m_internals->Iterate([&](CValidationInterface& callbacks) { callbacks.NotifyChainLock(pindex, clsig); });
285280
};
286281
ENQUEUE_AND_LOG_EVENT(event, "%s: notify chainlock at block=%s cl=%s", __func__,
287282
pindex->GetBlockHash().ToString(),
288-
clsig->ToString());
283+
id);
289284
}
290285

291-
void CMainSignals::NotifyGovernanceVote(const CDeterministicMNList& tip_mn_list, const std::shared_ptr<const CGovernanceVote>& vote) {
286+
void CMainSignals::NotifyGovernanceVote(const std::shared_ptr<CDeterministicMNList>& tip_mn_list, const std::shared_ptr<const CGovernanceVote>& vote, const std::string& id) {
292287
auto event = [vote, tip_mn_list, this] {
293288
m_internals->Iterate([&](CValidationInterface& callbacks) { callbacks.NotifyGovernanceVote(tip_mn_list, vote); });
294289
};
295-
ENQUEUE_AND_LOG_EVENT(event, "%s: notify governance vote: %s", __func__, vote->GetHash().ToString());
290+
ENQUEUE_AND_LOG_EVENT(event, "%s: notify governance vote: %s", __func__, id);
296291
}
297292

298-
void CMainSignals::NotifyGovernanceObject(const std::shared_ptr<const Governance::Object>& object) {
293+
void CMainSignals::NotifyGovernanceObject(const std::shared_ptr<const Governance::Object>& object, const std::string& id) {
299294
auto event = [object, this] {
300295
m_internals->Iterate([&](CValidationInterface& callbacks) { callbacks.NotifyGovernanceObject(object); });
301296
};
302-
ENQUEUE_AND_LOG_EVENT(event, "%s: notify governance object: %s", __func__, object->GetHash().ToString());
297+
ENQUEUE_AND_LOG_EVENT(event, "%s: notify governance object: %s", __func__, id);
303298
}
304299

305300
void CMainSignals::NotifyInstantSendDoubleSpendAttempt(const CTransactionRef& currentTx, const CTransactionRef& previousTx) {
@@ -311,12 +306,12 @@ void CMainSignals::NotifyInstantSendDoubleSpendAttempt(const CTransactionRef& cu
311306
previousTx->GetHash().ToString());
312307
}
313308

314-
void CMainSignals::NotifyRecoveredSig(const std::shared_ptr<const llmq::CRecoveredSig>& sig) {
309+
void CMainSignals::NotifyRecoveredSig(const std::shared_ptr<const llmq::CRecoveredSig>& sig, const std::string& id) {
315310
auto event = [sig, this] {
316311
m_internals->Iterate([&](CValidationInterface& callbacks) { callbacks.NotifyRecoveredSig(sig); });
317312
};
318313
ENQUEUE_AND_LOG_EVENT(event, "%s: notify recoveredsig=%s", __func__,
319-
sig->GetHash().ToString());
314+
id);
320315
}
321316

322317
void CMainSignals::NotifyMasternodeListChanged(bool undo, const CDeterministicMNList& oldMNList, const CDeterministicMNListDiff& diff) {

src/validationinterface.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ class CValidationInterface {
166166
virtual void BlockDisconnected(const std::shared_ptr<const CBlock> &block, const CBlockIndex *pindex) {}
167167
virtual void NotifyTransactionLock(const CTransactionRef &tx, const std::shared_ptr<const llmq::CInstantSendLock>& islock) {}
168168
virtual void NotifyChainLock(const CBlockIndex* pindex, const std::shared_ptr<const llmq::CChainLockSig>& clsig) {}
169-
virtual void NotifyGovernanceVote(const CDeterministicMNList& tip_mn_list, const std::shared_ptr<const CGovernanceVote>& vote) {}
169+
virtual void NotifyGovernanceVote(const std::shared_ptr<CDeterministicMNList>& tip_mn_list, const std::shared_ptr<const CGovernanceVote>& vote) {}
170170
virtual void NotifyGovernanceObject(const std::shared_ptr<const Governance::Object>& object) {}
171171
virtual void NotifyInstantSendDoubleSpendAttempt(const CTransactionRef& currentTx, const CTransactionRef& previousTx) {}
172172
virtual void NotifyRecoveredSig(const std::shared_ptr<const llmq::CRecoveredSig>& sig) {}
@@ -233,11 +233,11 @@ class CMainSignals {
233233
void BlockConnected(const std::shared_ptr<const CBlock> &, const CBlockIndex *pindex);
234234
void BlockDisconnected(const std::shared_ptr<const CBlock> &, const CBlockIndex* pindex);
235235
void NotifyTransactionLock(const CTransactionRef &tx, const std::shared_ptr<const llmq::CInstantSendLock>& islock);
236-
void NotifyChainLock(const CBlockIndex* pindex, const std::shared_ptr<const llmq::CChainLockSig>& clsig);
237-
void NotifyGovernanceVote(const CDeterministicMNList& tip_mn_list, const std::shared_ptr<const CGovernanceVote>& vote);
238-
void NotifyGovernanceObject(const std::shared_ptr<const Governance::Object>& object);
236+
void NotifyChainLock(const CBlockIndex* pindex, const std::shared_ptr<const llmq::CChainLockSig>& clsig, const std::string& id);
237+
void NotifyGovernanceVote(const std::shared_ptr<CDeterministicMNList>& tip_mn_list, const std::shared_ptr<const CGovernanceVote>& vote, const std::string& id);
238+
void NotifyGovernanceObject(const std::shared_ptr<const Governance::Object>& object, const std::string& id);
239239
void NotifyInstantSendDoubleSpendAttempt(const CTransactionRef &currentTx, const CTransactionRef &previousTx);
240-
void NotifyRecoveredSig(const std::shared_ptr<const llmq::CRecoveredSig> &sig);
240+
void NotifyRecoveredSig(const std::shared_ptr<const llmq::CRecoveredSig> &sig, const std::string& id);
241241
void NotifyMasternodeListChanged(bool undo, const CDeterministicMNList& oldMNList, const CDeterministicMNListDiff& diff);
242242
void ChainStateFlushed(const CBlockLocator &);
243243
void BlockChecked(const CBlock&, const BlockValidationState&);

src/zmq/zmqabstractnotifier.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ bool CZMQAbstractNotifier::NotifyTransactionLock(const CTransactionRef &/*transa
5353
return true;
5454
}
5555

56-
bool CZMQAbstractNotifier::NotifyGovernanceVote(const CDeterministicMNList& /*tip_mn_list*/, const std::shared_ptr<const CGovernanceVote> & /*vote*/)
56+
bool CZMQAbstractNotifier::NotifyGovernanceVote(const std::shared_ptr<CDeterministicMNList>& /*tip_mn_list*/, const std::shared_ptr<const CGovernanceVote> & /*vote*/)
5757
{
5858
return true;
5959
}

src/zmq/zmqabstractnotifier.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ class CZMQAbstractNotifier
7272
virtual bool NotifyTransaction(const CTransaction &transaction);
7373
virtual bool NotifyChainLock(const CBlockIndex *pindex, const std::shared_ptr<const llmq::CChainLockSig>& clsig);
7474
virtual bool NotifyTransactionLock(const CTransactionRef& transaction, const std::shared_ptr<const llmq::CInstantSendLock>& islock);
75-
virtual bool NotifyGovernanceVote(const CDeterministicMNList& tip_mn_list, const std::shared_ptr<const CGovernanceVote>& vote);
75+
virtual bool NotifyGovernanceVote(const std::shared_ptr<CDeterministicMNList>& tip_mn_list, const std::shared_ptr<const CGovernanceVote>& vote);
7676
virtual bool NotifyGovernanceObject(const std::shared_ptr<const Governance::Object>& object);
7777
virtual bool NotifyInstantSendDoubleSpendAttempt(const CTransactionRef& currentTx, const CTransactionRef& previousTx);
7878
virtual bool NotifyRecoveredSig(const std::shared_ptr<const llmq::CRecoveredSig>& sig);

src/zmq/zmqnotificationinterface.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ void CZMQNotificationInterface::NotifyTransactionLock(const CTransactionRef& tx,
220220
});
221221
}
222222

223-
void CZMQNotificationInterface::NotifyGovernanceVote(const CDeterministicMNList& tip_mn_list, const std::shared_ptr<const CGovernanceVote> &vote)
223+
void CZMQNotificationInterface::NotifyGovernanceVote(const std::shared_ptr<CDeterministicMNList>& tip_mn_list, const std::shared_ptr<const CGovernanceVote> &vote)
224224
{
225225
TryForEachAndRemoveFailed(notifiers, [&tip_mn_list, &vote](CZMQAbstractNotifier* notifier) {
226226
return notifier->NotifyGovernanceVote(tip_mn_list, vote);

0 commit comments

Comments
 (0)