-
Notifications
You must be signed in to change notification settings - Fork 1.2k
refactor: remove dependency of llmq/chainlocks, llmq/quorum_block_processor, ehf_signals on PeerManager #6292
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 6 commits
cab700a
d54b3ee
09565fe
5383421
f1c6d17
1d13f01
d0f1778
c77216e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,7 +11,6 @@ | |
| #include <chainparams.h> | ||
| #include <consensus/validation.h> | ||
| #include <masternode/sync.h> | ||
| #include <net_processing.h> | ||
| #include <node/blockstorage.h> | ||
| #include <node/ui_interface.h> | ||
| #include <scheduler.h> | ||
|
|
@@ -23,25 +22,29 @@ | |
| #include <validation.h> | ||
| #include <validationinterface.h> | ||
|
|
||
| static bool ChainLocksSigningEnabled(const CSporkManager& sporkman) | ||
| { | ||
| return sporkman.GetSporkValue(SPORK_19_CHAINLOCKS_ENABLED) == 0; | ||
| } | ||
|
|
||
| namespace llmq | ||
| { | ||
| std::unique_ptr<CChainLocksHandler> chainLocksHandler; | ||
|
|
||
| CChainLocksHandler::CChainLocksHandler(CChainState& chainstate, CQuorumManager& _qman, CSigningManager& _sigman, | ||
| CSigSharesManager& _shareman, CSporkManager& sporkman, CTxMemPool& _mempool, | ||
| const CMasternodeSync& mn_sync, const std::unique_ptr<PeerManager>& peerman, | ||
| bool is_masternode) : | ||
| const CMasternodeSync& mn_sync, bool is_masternode) : | ||
| m_chainstate(chainstate), | ||
| qman(_qman), | ||
| sigman(_sigman), | ||
| shareman(_shareman), | ||
| spork_manager(sporkman), | ||
| mempool(_mempool), | ||
| m_mn_sync(mn_sync), | ||
| m_peerman(peerman), | ||
| m_is_masternode{is_masternode}, | ||
| scheduler(std::make_unique<CScheduler>()), | ||
| scheduler_thread(std::make_unique<std::thread>(std::thread(util::TraceThread, "cl-schdlr", [&] { scheduler->serviceQueue(); }))) | ||
| scheduler_thread( | ||
| std::make_unique<std::thread>(std::thread(util::TraceThread, "cl-schdlr", [&] { scheduler->serviceQueue(); }))) | ||
| { | ||
| } | ||
|
|
||
|
|
@@ -93,31 +96,11 @@ CChainLockSig CChainLocksHandler::GetBestChainLock() const | |
| return bestChainLock; | ||
| } | ||
|
|
||
| PeerMsgRet CChainLocksHandler::ProcessMessage(const CNode& pfrom, const std::string& msg_type, CDataStream& vRecv) | ||
| { | ||
| if (!AreChainLocksEnabled(spork_manager)) { | ||
| return {}; | ||
| } | ||
|
|
||
| if (msg_type == NetMsgType::CLSIG) { | ||
| CChainLockSig clsig; | ||
| vRecv >> clsig; | ||
|
|
||
| return ProcessNewChainLock(pfrom.GetId(), clsig, ::SerializeHash(clsig)); | ||
| } | ||
| return {}; | ||
| } | ||
|
|
||
| PeerMsgRet CChainLocksHandler::ProcessNewChainLock(const NodeId from, const llmq::CChainLockSig& clsig, const uint256& hash) | ||
| MessageProcessingResult CChainLocksHandler::ProcessNewChainLock(const NodeId from, const llmq::CChainLockSig& clsig, | ||
| const uint256& hash) | ||
| { | ||
| CheckActiveState(); | ||
|
|
||
| CInv clsigInv(MSG_CLSIG, hash); | ||
|
|
||
| if (from != -1) { | ||
| WITH_LOCK(::cs_main, Assert(m_peerman)->EraseObjectRequest(from, clsigInv)); | ||
| } | ||
|
|
||
| { | ||
| LOCK(cs); | ||
| if (!seenChainLocks.emplace(hash, GetTimeMillis()).second) { | ||
|
|
@@ -133,7 +116,7 @@ PeerMsgRet CChainLocksHandler::ProcessNewChainLock(const NodeId from, const llmq | |
| if (const auto ret = VerifyChainLock(clsig); ret != VerifyRecSigStatus::Valid) { | ||
| LogPrint(BCLog::CHAINLOCKS, "CChainLocksHandler::%s -- invalid CLSIG (%s), status=%d peer=%d\n", __func__, clsig.ToString(), ToUnderlying(ret), from); | ||
| if (from != -1) { | ||
| return tl::unexpected{10}; | ||
| return MisbehavingError{10}; | ||
| } | ||
| return {}; | ||
| } | ||
|
|
@@ -162,14 +145,12 @@ PeerMsgRet CChainLocksHandler::ProcessNewChainLock(const NodeId from, const llmq | |
| // Note: make sure to still relay clsig further. | ||
| } | ||
|
|
||
| // Note: do not hold cs while calling RelayInv | ||
| AssertLockNotHeld(cs); | ||
| Assert(m_peerman)->RelayInv(clsigInv); | ||
| CInv clsigInv(MSG_CLSIG, hash); | ||
|
|
||
| if (pindex == nullptr) { | ||
| // we don't know the block/header for this CLSIG yet, so bail out for now | ||
| // when the block or the header later comes in, we will enforce the correct chain | ||
| return {}; | ||
| return clsigInv; | ||
| } | ||
|
|
||
| scheduler->scheduleFromNow([&]() { | ||
|
|
@@ -179,7 +160,7 @@ PeerMsgRet CChainLocksHandler::ProcessNewChainLock(const NodeId from, const llmq | |
|
|
||
| LogPrint(BCLog::CHAINLOCKS, "CChainLocksHandler::%s -- processed new CLSIG (%s), peer=%d\n", | ||
| __func__, clsig.ToString(), from); | ||
| return {}; | ||
| return clsigInv; | ||
| } | ||
|
|
||
| void CChainLocksHandler::AcceptedBlockHeader(gsl::not_null<const CBlockIndex*> pindexNew) | ||
|
|
@@ -520,10 +501,10 @@ void CChainLocksHandler::EnforceBestChainLock() | |
| uiInterface.NotifyChainLock(clsig->getBlockHash().ToString(), clsig->getHeight()); | ||
| } | ||
|
|
||
| void CChainLocksHandler::HandleNewRecoveredSig(const llmq::CRecoveredSig& recoveredSig) | ||
| MessageProcessingResult CChainLocksHandler::HandleNewRecoveredSig(const llmq::CRecoveredSig& recoveredSig) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm confused, this method doesn't doesn't return any error values? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
which belongs to |
||
| { | ||
| if (!isEnabled) { | ||
| return; | ||
| return {}; | ||
| } | ||
|
|
||
| CChainLockSig clsig; | ||
|
|
@@ -532,17 +513,17 @@ void CChainLocksHandler::HandleNewRecoveredSig(const llmq::CRecoveredSig& recove | |
|
|
||
| if (recoveredSig.getId() != lastSignedRequestId || recoveredSig.getMsgHash() != lastSignedMsgHash) { | ||
| // this is not what we signed, so lets not create a CLSIG for it | ||
| return; | ||
| return {}; | ||
| } | ||
| if (bestChainLock.getHeight() >= lastSignedHeight) { | ||
| // already got the same or a better CLSIG through the CLSIG message | ||
| return; | ||
| return {}; | ||
| } | ||
|
|
||
|
|
||
| clsig = CChainLockSig(lastSignedHeight, lastSignedMsgHash, recoveredSig.sig.Get()); | ||
| } | ||
| ProcessNewChainLock(-1, clsig, ::SerializeHash(clsig)); | ||
| return ProcessNewChainLock(-1, clsig, ::SerializeHash(clsig)); | ||
| } | ||
|
|
||
| bool CChainLocksHandler::HasChainLock(int nHeight, const uint256& blockHash) const | ||
|
|
@@ -678,9 +659,4 @@ bool AreChainLocksEnabled(const CSporkManager& sporkman) | |
| return sporkman.IsSporkActive(SPORK_19_CHAINLOCKS_ENABLED); | ||
| } | ||
|
|
||
| bool ChainLocksSigningEnabled(const CSporkManager& sporkman) | ||
| { | ||
| return sporkman.GetSporkValue(SPORK_19_CHAINLOCKS_ENABLED) == 0; | ||
| } | ||
|
|
||
| } // namespace llmq | ||
Uh oh!
There was an error while loading. Please reload this page.