mirror of
https://github.com/dashpay/dash.git
synced 2024-12-25 03:52:49 +01:00
refactor: drop usage of chainstate globals in masternode logic
This commit is contained in:
parent
303c6bb4db
commit
208b1c079b
@ -61,7 +61,8 @@ void CMNAuth::PushMNAUTH(CNode& peer, CConnman& connman, const CActiveMasternode
|
||||
}
|
||||
|
||||
PeerMsgRet CMNAuth::ProcessMessage(CNode& peer, CConnman& connman, CMasternodeMetaMan& mn_metaman, const CActiveMasternodeManager* const mn_activeman,
|
||||
const CMasternodeSync& mn_sync, const CDeterministicMNList& tip_mn_list, std::string_view msg_type, CDataStream& vRecv)
|
||||
const CChain& active_chain, const CMasternodeSync& mn_sync, const CDeterministicMNList& tip_mn_list,
|
||||
std::string_view msg_type, CDataStream& vRecv)
|
||||
{
|
||||
assert(mn_metaman.IsValid());
|
||||
|
||||
@ -105,7 +106,7 @@ PeerMsgRet CMNAuth::ProcessMessage(CNode& peer, CConnman& connman, CMasternodeMe
|
||||
if (Params().NetworkIDString() != CBaseChainParams::MAIN && gArgs.IsArgSet("-pushversion")) {
|
||||
nOurNodeVersion = gArgs.GetArg("-pushversion", PROTOCOL_VERSION);
|
||||
}
|
||||
const CBlockIndex* tip = ::ChainActive().Tip();
|
||||
const CBlockIndex* tip = active_chain.Tip();
|
||||
const bool is_basic_scheme_active{DeploymentActiveAfter(tip, Params().GetConsensus(), Consensus::DEPLOYMENT_V19)};
|
||||
ConstCBLSPublicKeyVersionWrapper pubKey(dmn->pdmnState->pubKeyOperator.Get(), !is_basic_scheme_active);
|
||||
// See comment in PushMNAUTH (fInbound is negated here as we're on the other side of the connection)
|
||||
|
@ -11,6 +11,7 @@
|
||||
|
||||
class CActiveMasternodeManager;
|
||||
class CBlockIndex;
|
||||
class CChain;
|
||||
class CConnman;
|
||||
class CDataStream;
|
||||
class CDeterministicMN;
|
||||
@ -59,7 +60,8 @@ public:
|
||||
* attempting to call this function regardless of sync state
|
||||
*/
|
||||
static PeerMsgRet ProcessMessage(CNode& peer, CConnman& connman, CMasternodeMetaMan& mn_metaman, const CActiveMasternodeManager* const mn_activeman,
|
||||
const CMasternodeSync& mn_sync, const CDeterministicMNList& tip_mn_list, std::string_view msg_type, CDataStream& vRecv);
|
||||
const CChain& active_chain, const CMasternodeSync& mn_sync, const CDeterministicMNList& tip_mn_list,
|
||||
std::string_view msg_type, CDataStream& vRecv);
|
||||
static void NotifyMasternodeListChanged(bool undo, const CDeterministicMNList& oldMNList, const CDeterministicMNListDiff& diff, CConnman& connman);
|
||||
};
|
||||
|
||||
|
@ -101,7 +101,7 @@ bool MNHFTx::Verify(const llmq::CQuorumManager& qman, const uint256& quorumHash,
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CheckMNHFTx(const llmq::CQuorumManager& qman, const CTransaction& tx, const CBlockIndex* pindexPrev, TxValidationState& state)
|
||||
bool CheckMNHFTx(const ChainstateManager& chainman, const llmq::CQuorumManager& qman, const CTransaction& tx, const CBlockIndex* pindexPrev, TxValidationState& state)
|
||||
{
|
||||
if (!tx.IsSpecialTxVersion() || tx.nType != TRANSACTION_MNHF_SIGNAL) {
|
||||
return state.Invalid(TxValidationResult::TX_CONSENSUS, "bad-mnhf-type");
|
||||
@ -116,7 +116,7 @@ bool CheckMNHFTx(const llmq::CQuorumManager& qman, const CTransaction& tx, const
|
||||
return state.Invalid(TxValidationResult::TX_CONSENSUS, "bad-mnhf-version");
|
||||
}
|
||||
|
||||
const CBlockIndex* pindexQuorum = WITH_LOCK(::cs_main, return g_chainman.m_blockman.LookupBlockIndex(mnhfTx.signal.quorumHash));
|
||||
const CBlockIndex* pindexQuorum = WITH_LOCK(::cs_main, return chainman.m_blockman.LookupBlockIndex(mnhfTx.signal.quorumHash));
|
||||
if (!pindexQuorum) {
|
||||
return state.Invalid(TxValidationResult::TX_CONSENSUS, "bad-mnhf-quorum-hash");
|
||||
}
|
||||
@ -160,7 +160,7 @@ std::optional<uint8_t> extractEHFSignal(const CTransaction& tx)
|
||||
return opt_mnhfTx->signal.versionBit;
|
||||
}
|
||||
|
||||
static bool extractSignals(const llmq::CQuorumManager& qman, const CBlock& block, const CBlockIndex* const pindex, std::vector<uint8_t>& new_signals, BlockValidationState& state)
|
||||
static bool extractSignals(const ChainstateManager& chainman, const llmq::CQuorumManager& qman, const CBlock& block, const CBlockIndex* const pindex, std::vector<uint8_t>& new_signals, BlockValidationState& state)
|
||||
{
|
||||
// we skip the coinbase
|
||||
for (size_t i = 1; i < block.vtx.size(); ++i) {
|
||||
@ -172,7 +172,7 @@ static bool extractSignals(const llmq::CQuorumManager& qman, const CBlock& block
|
||||
}
|
||||
|
||||
TxValidationState tx_state;
|
||||
if (!CheckMNHFTx(qman, tx, pindex, tx_state)) {
|
||||
if (!CheckMNHFTx(chainman, qman, tx, pindex, tx_state)) {
|
||||
return state.Invalid(BlockValidationResult::BLOCK_CONSENSUS, tx_state.GetRejectReason(), tx_state.GetDebugMessage());
|
||||
}
|
||||
|
||||
@ -192,11 +192,11 @@ static bool extractSignals(const llmq::CQuorumManager& qman, const CBlock& block
|
||||
|
||||
std::optional<CMNHFManager::Signals> CMNHFManager::ProcessBlock(const CBlock& block, const CBlockIndex* const pindex, bool fJustCheck, BlockValidationState& state)
|
||||
{
|
||||
assert(m_qman);
|
||||
assert(m_chainman && m_qman);
|
||||
|
||||
try {
|
||||
std::vector<uint8_t> new_signals;
|
||||
if (!extractSignals(*m_qman, block, pindex, new_signals, state)) {
|
||||
if (!extractSignals(*m_chainman, *m_qman, block, pindex, new_signals, state)) {
|
||||
// state is set inside extractSignals
|
||||
return std::nullopt;
|
||||
}
|
||||
@ -246,11 +246,11 @@ std::optional<CMNHFManager::Signals> CMNHFManager::ProcessBlock(const CBlock& bl
|
||||
|
||||
bool CMNHFManager::UndoBlock(const CBlock& block, const CBlockIndex* const pindex)
|
||||
{
|
||||
assert(m_qman);
|
||||
assert(m_chainman && m_qman);
|
||||
|
||||
std::vector<uint8_t> excluded_signals;
|
||||
BlockValidationState state;
|
||||
if (!extractSignals(*m_qman, block, pindex, excluded_signals, state)) {
|
||||
if (!extractSignals(*m_chainman, *m_qman, block, pindex, excluded_signals, state)) {
|
||||
LogPrintf("CMNHFManager::%s: failed to extract signals\n", __func__);
|
||||
return false;
|
||||
}
|
||||
@ -354,10 +354,11 @@ void CMNHFManager::AddSignal(const CBlockIndex* const pindex, int bit)
|
||||
AddToCache(signals, pindex);
|
||||
}
|
||||
|
||||
void CMNHFManager::ConnectManagers(gsl::not_null<llmq::CQuorumManager*> qman)
|
||||
void CMNHFManager::ConnectManagers(gsl::not_null<ChainstateManager*> chainman, gsl::not_null<llmq::CQuorumManager*> qman)
|
||||
{
|
||||
// Do not allow double-initialization
|
||||
assert(m_qman == nullptr);
|
||||
assert(m_chainman == nullptr && m_qman == nullptr);
|
||||
m_chainman = chainman;
|
||||
m_qman = qman;
|
||||
}
|
||||
|
||||
|
@ -22,6 +22,7 @@ class BlockValidationState;
|
||||
class CBlock;
|
||||
class CBlockIndex;
|
||||
class CEvoDB;
|
||||
class ChainstateManager;
|
||||
class TxValidationState;
|
||||
namespace llmq {
|
||||
class CQuorumManager;
|
||||
@ -100,6 +101,7 @@ class CMNHFManager : public AbstractEHFManager
|
||||
{
|
||||
private:
|
||||
CEvoDB& m_evoDb;
|
||||
ChainstateManager* m_chainman{nullptr};
|
||||
llmq::CQuorumManager* m_qman{nullptr};
|
||||
|
||||
static constexpr size_t MNHFCacheSize = 1000;
|
||||
@ -147,14 +149,14 @@ public:
|
||||
* Separated from constructor to allow LLMQContext to use CMNHFManager in read-only capacity.
|
||||
* Required to mutate state.
|
||||
*/
|
||||
void ConnectManagers(gsl::not_null<llmq::CQuorumManager*> qman);
|
||||
void ConnectManagers(gsl::not_null<ChainstateManager*> chainman, gsl::not_null<llmq::CQuorumManager*> qman);
|
||||
|
||||
/**
|
||||
* Reset llmq::CQuorumManager pointer.
|
||||
*
|
||||
* @pre Must be called before LLMQContext (containing llmq::CQuorumManager) is destroyed.
|
||||
*/
|
||||
void DisconnectManagers() { m_qman = nullptr; };
|
||||
void DisconnectManagers() { m_chainman = nullptr; m_qman = nullptr; };
|
||||
|
||||
private:
|
||||
void AddToCache(const Signals& signals, const CBlockIndex* const pindex);
|
||||
@ -175,6 +177,6 @@ private:
|
||||
};
|
||||
|
||||
std::optional<uint8_t> extractEHFSignal(const CTransaction& tx);
|
||||
bool CheckMNHFTx(const llmq::CQuorumManager& qman, const CTransaction& tx, const CBlockIndex* pindexPrev, TxValidationState& state);
|
||||
bool CheckMNHFTx(const ChainstateManager& chainman, const llmq::CQuorumManager& qman, const CTransaction& tx, const CBlockIndex* pindexPrev, TxValidationState& state);
|
||||
|
||||
#endif // BITCOIN_EVO_MNHFTX_H
|
||||
|
@ -316,29 +316,29 @@ CSimplifiedMNListDiff BuildSimplifiedDiff(const CDeterministicMNList& from, cons
|
||||
return diffRet;
|
||||
}
|
||||
|
||||
bool BuildSimplifiedMNListDiff(const uint256& baseBlockHash, const uint256& blockHash, CSimplifiedMNListDiff& mnListDiffRet,
|
||||
CDeterministicMNManager& dmnman, const llmq::CQuorumBlockProcessor& quorum_block_processor, const llmq::CQuorumManager& qman,
|
||||
std::string& errorRet, bool extended)
|
||||
bool BuildSimplifiedMNListDiff(CDeterministicMNManager& dmnman, const ChainstateManager& chainman, const llmq::CQuorumBlockProcessor& qblockman,
|
||||
const llmq::CQuorumManager& qman, const uint256& baseBlockHash, const uint256& blockHash,
|
||||
CSimplifiedMNListDiff& mnListDiffRet, std::string& errorRet, bool extended)
|
||||
{
|
||||
AssertLockHeld(cs_main);
|
||||
mnListDiffRet = CSimplifiedMNListDiff();
|
||||
|
||||
const CBlockIndex* baseBlockIndex = ::ChainActive().Genesis();
|
||||
const CBlockIndex* baseBlockIndex = chainman.ActiveChain().Genesis();
|
||||
if (!baseBlockHash.IsNull()) {
|
||||
baseBlockIndex = g_chainman.m_blockman.LookupBlockIndex(baseBlockHash);
|
||||
baseBlockIndex = chainman.m_blockman.LookupBlockIndex(baseBlockHash);
|
||||
if (!baseBlockIndex) {
|
||||
errorRet = strprintf("block %s not found", baseBlockHash.ToString());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
const CBlockIndex* blockIndex = g_chainman.m_blockman.LookupBlockIndex(blockHash);
|
||||
const CBlockIndex* blockIndex = chainman.m_blockman.LookupBlockIndex(blockHash);
|
||||
if (!blockIndex) {
|
||||
errorRet = strprintf("block %s not found", blockHash.ToString());
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!::ChainActive().Contains(baseBlockIndex) || !::ChainActive().Contains(blockIndex)) {
|
||||
if (!chainman.ActiveChain().Contains(baseBlockIndex) || !chainman.ActiveChain().Contains(blockIndex)) {
|
||||
errorRet = strprintf("block %s and %s are not in the same chain", baseBlockHash.ToString(), blockHash.ToString());
|
||||
return false;
|
||||
}
|
||||
@ -356,7 +356,7 @@ bool BuildSimplifiedMNListDiff(const uint256& baseBlockHash, const uint256& bloc
|
||||
// null block hash was provided to get the diff from the genesis block.
|
||||
mnListDiffRet.baseBlockHash = baseBlockHash;
|
||||
|
||||
if (!mnListDiffRet.BuildQuorumsDiff(baseBlockIndex, blockIndex, quorum_block_processor)) {
|
||||
if (!mnListDiffRet.BuildQuorumsDiff(baseBlockIndex, blockIndex, qblockman)) {
|
||||
errorRet = strprintf("failed to build quorums diff");
|
||||
return false;
|
||||
}
|
||||
|
@ -16,6 +16,7 @@ class UniValue;
|
||||
class CBlockIndex;
|
||||
class CDeterministicMNList;
|
||||
class CDeterministicMN;
|
||||
class ChainstateManager;
|
||||
|
||||
namespace llmq {
|
||||
class CFinalCommitment;
|
||||
@ -170,8 +171,8 @@ public:
|
||||
[[nodiscard]] UniValue ToJson(bool extended = false) const;
|
||||
};
|
||||
|
||||
bool BuildSimplifiedMNListDiff(const uint256& baseBlockHash, const uint256& blockHash, CSimplifiedMNListDiff& mnListDiffRet,
|
||||
CDeterministicMNManager& dmnman, const llmq::CQuorumBlockProcessor& quorum_block_processor, const llmq::CQuorumManager& qman,
|
||||
std::string& errorRet, bool extended = false);
|
||||
bool BuildSimplifiedMNListDiff(CDeterministicMNManager& dmnman, const ChainstateManager& chainman, const llmq::CQuorumBlockProcessor& qblockman,
|
||||
const llmq::CQuorumManager& qman, const uint256& baseBlockHash, const uint256& blockHash,
|
||||
CSimplifiedMNListDiff& mnListDiffRet, std::string& errorRet, bool extended = false);
|
||||
|
||||
#endif // BITCOIN_EVO_SIMPLIFIEDMNS_H
|
||||
|
@ -51,7 +51,7 @@ static bool CheckSpecialTxInner(CDeterministicMNManager& dmnman, const Chainstat
|
||||
if (!DeploymentActiveAfter(pindexPrev, consensusParams, Consensus::DEPLOYMENT_V20)) {
|
||||
return state.Invalid(TxValidationResult::TX_CONSENSUS, "mnhf-before-v20");
|
||||
}
|
||||
return CheckMNHFTx(qman, tx, pindexPrev, state);
|
||||
return CheckMNHFTx(chainman, qman, tx, pindexPrev, state);
|
||||
case TRANSACTION_ASSET_LOCK:
|
||||
if (!DeploymentActiveAfter(pindexPrev, consensusParams, Consensus::DEPLOYMENT_V20)) {
|
||||
return state.Invalid(TxValidationResult::TX_CONSENSUS, "assetlocks-before-v20");
|
||||
|
@ -2016,7 +2016,7 @@ bool AppInitMain(const CoreContext& context, NodeContext& node, interfaces::Bloc
|
||||
node.llmq_ctx = std::make_unique<LLMQContext>(chainman.ActiveChainstate(), *node.connman, *node.dmnman, *node.evodb, *node.mn_metaman, *node.mnhf_manager, *node.sporkman,
|
||||
*node.mempool, node.mn_activeman.get(), *node.mn_sync, node.peerman, /* unit_tests = */ false, /* wipe = */ fReset || fReindexChainState);
|
||||
// Enable CMNHFManager::{Process, Undo}Block
|
||||
node.mnhf_manager->ConnectManagers(node.llmq_ctx->qman.get());
|
||||
node.mnhf_manager->ConnectManagers(node.chainman, node.llmq_ctx->qman.get());
|
||||
// Have to start it early to let VerifyDB check ChainLock signatures in coinbase
|
||||
node.llmq_ctx->Start();
|
||||
|
||||
|
@ -85,9 +85,9 @@ UniValue CQuorumRotationInfo::ToJson() const
|
||||
return obj;
|
||||
}
|
||||
|
||||
bool BuildQuorumRotationInfo(const CGetQuorumRotationInfo& request, CQuorumRotationInfo& response,
|
||||
CDeterministicMNManager& dmnman, const ChainstateManager& chainman, const CQuorumManager& qman,
|
||||
const CQuorumBlockProcessor& quorum_block_processor, std::string& errorRet)
|
||||
bool BuildQuorumRotationInfo(CDeterministicMNManager& dmnman, const ChainstateManager& chainman, const CQuorumManager& qman,
|
||||
const CQuorumBlockProcessor& qblockman, const CGetQuorumRotationInfo& request,
|
||||
CQuorumRotationInfo& response, std::string& errorRet)
|
||||
{
|
||||
AssertLockHeld(cs_main);
|
||||
|
||||
@ -123,7 +123,7 @@ bool BuildQuorumRotationInfo(const CGetQuorumRotationInfo& request, CQuorumRotat
|
||||
return false;
|
||||
}
|
||||
//Build MN list Diff always with highest baseblock
|
||||
if (!BuildSimplifiedMNListDiff(baseBlockIndexes.back()->GetBlockHash(), tipBlockIndex->GetBlockHash(), response.mnListDiffTip, dmnman, quorum_block_processor, qman, errorRet)) {
|
||||
if (!BuildSimplifiedMNListDiff(dmnman, chainman, qblockman, qman, baseBlockIndexes.back()->GetBlockHash(), tipBlockIndex->GetBlockHash(), response.mnListDiffTip, errorRet)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -156,7 +156,7 @@ bool BuildQuorumRotationInfo(const CGetQuorumRotationInfo& request, CQuorumRotat
|
||||
}
|
||||
|
||||
//Build MN list Diff always with highest baseblock
|
||||
if (!BuildSimplifiedMNListDiff(GetLastBaseBlockHash(baseBlockIndexes, pWorkBlockIndex), pWorkBlockIndex->GetBlockHash(), response.mnListDiffH, dmnman, quorum_block_processor, qman, errorRet)) {
|
||||
if (!BuildSimplifiedMNListDiff(dmnman, chainman, qblockman, qman, GetLastBaseBlockHash(baseBlockIndexes, pWorkBlockIndex), pWorkBlockIndex->GetBlockHash(), response.mnListDiffH, errorRet)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -202,7 +202,7 @@ bool BuildQuorumRotationInfo(const CGetQuorumRotationInfo& request, CQuorumRotat
|
||||
const CBlockIndex* pWorkBlockHMinus4CIndex = pBlockHMinus4CIndex->GetAncestor(pBlockHMinus4CIndex->nHeight - workDiff);
|
||||
//Checked later if extraShare is on
|
||||
|
||||
if (!BuildSimplifiedMNListDiff(GetLastBaseBlockHash(baseBlockIndexes, pWorkBlockHMinusCIndex), pWorkBlockHMinusCIndex->GetBlockHash(), response.mnListDiffAtHMinusC, dmnman, quorum_block_processor, qman, errorRet)) {
|
||||
if (!BuildSimplifiedMNListDiff(dmnman, chainman, qblockman, qman, GetLastBaseBlockHash(baseBlockIndexes, pWorkBlockHMinusCIndex), pWorkBlockHMinusCIndex->GetBlockHash(), response.mnListDiffAtHMinusC, errorRet)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -214,7 +214,7 @@ bool BuildQuorumRotationInfo(const CGetQuorumRotationInfo& request, CQuorumRotat
|
||||
response.quorumSnapshotAtHMinusC = std::move(snapshotHMinusC.value());
|
||||
}
|
||||
|
||||
if (!BuildSimplifiedMNListDiff(GetLastBaseBlockHash(baseBlockIndexes, pWorkBlockHMinus2CIndex), pWorkBlockHMinus2CIndex->GetBlockHash(), response.mnListDiffAtHMinus2C, dmnman, quorum_block_processor, qman, errorRet)) {
|
||||
if (!BuildSimplifiedMNListDiff(dmnman, chainman, qblockman, qman, GetLastBaseBlockHash(baseBlockIndexes, pWorkBlockHMinus2CIndex), pWorkBlockHMinus2CIndex->GetBlockHash(), response.mnListDiffAtHMinus2C, errorRet)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -226,7 +226,7 @@ bool BuildQuorumRotationInfo(const CGetQuorumRotationInfo& request, CQuorumRotat
|
||||
response.quorumSnapshotAtHMinus2C = std::move(snapshotHMinus2C.value());
|
||||
}
|
||||
|
||||
if (!BuildSimplifiedMNListDiff(GetLastBaseBlockHash(baseBlockIndexes, pWorkBlockHMinus3CIndex), pWorkBlockHMinus3CIndex->GetBlockHash(), response.mnListDiffAtHMinus3C, dmnman, quorum_block_processor, qman, errorRet)) {
|
||||
if (!BuildSimplifiedMNListDiff(dmnman, chainman, qblockman, qman, GetLastBaseBlockHash(baseBlockIndexes, pWorkBlockHMinus3CIndex), pWorkBlockHMinus3CIndex->GetBlockHash(), response.mnListDiffAtHMinus3C, errorRet)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -255,7 +255,7 @@ bool BuildQuorumRotationInfo(const CGetQuorumRotationInfo& request, CQuorumRotat
|
||||
}
|
||||
|
||||
CSimplifiedMNListDiff mn4c;
|
||||
if (!BuildSimplifiedMNListDiff(GetLastBaseBlockHash(baseBlockIndexes, pWorkBlockHMinus4CIndex), pWorkBlockHMinus4CIndex->GetBlockHash(), mn4c, dmnman, quorum_block_processor, qman, errorRet)) {
|
||||
if (!BuildSimplifiedMNListDiff(dmnman, chainman, qblockman, qman, GetLastBaseBlockHash(baseBlockIndexes, pWorkBlockHMinus4CIndex), pWorkBlockHMinus4CIndex->GetBlockHash(), mn4c, errorRet)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -268,11 +268,11 @@ bool BuildQuorumRotationInfo(const CGetQuorumRotationInfo& request, CQuorumRotat
|
||||
|
||||
std::set<int> snapshotHeightsNeeded;
|
||||
|
||||
std::vector<std::pair<int, const CBlockIndex*>> qdata = quorum_block_processor.GetLastMinedCommitmentsPerQuorumIndexUntilBlock(llmqType, blockIndex, 0);
|
||||
std::vector<std::pair<int, const CBlockIndex*>> qdata = qblockman.GetLastMinedCommitmentsPerQuorumIndexUntilBlock(llmqType, blockIndex, 0);
|
||||
|
||||
for (const auto& obj : qdata) {
|
||||
uint256 minedBlockHash;
|
||||
llmq::CFinalCommitmentPtr qc = quorum_block_processor.GetMinedCommitment(llmqType, obj.second->GetBlockHash(), minedBlockHash);
|
||||
llmq::CFinalCommitmentPtr qc = qblockman.GetMinedCommitment(llmqType, obj.second->GetBlockHash(), minedBlockHash);
|
||||
if (qc == nullptr) {
|
||||
return false;
|
||||
}
|
||||
@ -311,7 +311,7 @@ bool BuildQuorumRotationInfo(const CGetQuorumRotationInfo& request, CQuorumRotat
|
||||
}
|
||||
|
||||
CSimplifiedMNListDiff mnhneeded;
|
||||
if (!BuildSimplifiedMNListDiff(GetLastBaseBlockHash(baseBlockIndexes, pNeededWorkBlockIndex), pNeededWorkBlockIndex->GetBlockHash(), mnhneeded, dmnman, quorum_block_processor, qman, errorRet)) {
|
||||
if (!BuildSimplifiedMNListDiff(dmnman, chainman, qblockman, qman, GetLastBaseBlockHash(baseBlockIndexes, pNeededWorkBlockIndex), pNeededWorkBlockIndex->GetBlockHash(), mnhneeded, errorRet)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -207,9 +207,9 @@ public:
|
||||
[[nodiscard]] UniValue ToJson() const;
|
||||
};
|
||||
|
||||
bool BuildQuorumRotationInfo(const CGetQuorumRotationInfo& request, CQuorumRotationInfo& response,
|
||||
CDeterministicMNManager& dmnman, const ChainstateManager& chainman, const CQuorumManager& qman,
|
||||
const CQuorumBlockProcessor& quorumBlockProcessor, std::string& errorRet);
|
||||
bool BuildQuorumRotationInfo(CDeterministicMNManager& dmnman, const ChainstateManager& chainman, const CQuorumManager& qman,
|
||||
const CQuorumBlockProcessor& qblockman, const CGetQuorumRotationInfo& request,
|
||||
CQuorumRotationInfo& response, std::string& errorRet);
|
||||
uint256 GetLastBaseBlockHash(Span<const CBlockIndex*> baseBlockIndexes, const CBlockIndex* blockIndex);
|
||||
|
||||
class CQuorumSnapshotManager
|
||||
|
@ -4803,7 +4803,9 @@ void PeerManagerImpl::ProcessMessage(
|
||||
|
||||
CSimplifiedMNListDiff mnListDiff;
|
||||
std::string strError;
|
||||
if (BuildSimplifiedMNListDiff(cmd.baseBlockHash, cmd.blockHash, mnListDiff, *m_dmnman, *m_llmq_ctx->quorum_block_processor, *m_llmq_ctx->qman, strError)) {
|
||||
if (BuildSimplifiedMNListDiff(*m_dmnman, m_chainman, *m_llmq_ctx->quorum_block_processor, *m_llmq_ctx->qman,
|
||||
cmd.baseBlockHash, cmd.blockHash, mnListDiff, strError))
|
||||
{
|
||||
m_connman.PushMessage(&pfrom, msgMaker.Make(NetMsgType::MNLISTDIFF, mnListDiff));
|
||||
} else {
|
||||
strError = strprintf("getmnlistdiff failed for baseBlockHash=%s, blockHash=%s. error=%s", cmd.baseBlockHash.ToString(), cmd.blockHash.ToString(), strError);
|
||||
@ -4842,7 +4844,7 @@ void PeerManagerImpl::ProcessMessage(
|
||||
|
||||
llmq::CQuorumRotationInfo quorumRotationInfoRet;
|
||||
std::string strError;
|
||||
if (BuildQuorumRotationInfo(cmd, quorumRotationInfoRet, *m_dmnman, m_chainman, *m_llmq_ctx->qman, *m_llmq_ctx->quorum_block_processor, strError)) {
|
||||
if (BuildQuorumRotationInfo(*m_dmnman, m_chainman, *m_llmq_ctx->qman, *m_llmq_ctx->quorum_block_processor, cmd, quorumRotationInfoRet, strError)) {
|
||||
m_connman.PushMessage(&pfrom, msgMaker.Make(NetMsgType::QUORUMROTATIONINFO, quorumRotationInfoRet));
|
||||
} else {
|
||||
strError = strprintf("getquorumrotationinfo failed for size(baseBlockHashes)=%d, blockRequestHash=%s. error=%s", cmd.baseBlockHashes.size(), cmd.blockRequestHash.ToString(), strError);
|
||||
@ -4904,7 +4906,7 @@ void PeerManagerImpl::ProcessMessage(
|
||||
ProcessPeerMsgRet(m_sporkman.ProcessMessage(pfrom, m_connman, *this, msg_type, vRecv), pfrom);
|
||||
m_mn_sync.ProcessMessage(pfrom, msg_type, vRecv);
|
||||
ProcessPeerMsgRet(m_govman.ProcessMessage(pfrom, m_connman, *this, msg_type, vRecv), pfrom);
|
||||
ProcessPeerMsgRet(CMNAuth::ProcessMessage(pfrom, m_connman, m_mn_metaman, m_mn_activeman, m_mn_sync, m_dmnman->GetListAtChainTip(), msg_type, vRecv), pfrom);
|
||||
ProcessPeerMsgRet(CMNAuth::ProcessMessage(pfrom, m_connman, m_mn_metaman, m_mn_activeman, m_chainman.ActiveChain(), m_mn_sync, m_dmnman->GetListAtChainTip(), msg_type, vRecv), pfrom);
|
||||
ProcessPeerMsgRet(m_llmq_ctx->quorum_block_processor->ProcessMessage(pfrom, msg_type, vRecv), pfrom);
|
||||
ProcessPeerMsgRet(m_llmq_ctx->qdkgsman->ProcessMessage(pfrom, this, is_masternode, msg_type, vRecv), pfrom);
|
||||
ProcessPeerMsgRet(m_llmq_ctx->qman->ProcessMessage(pfrom, msg_type, vRecv), pfrom);
|
||||
|
@ -1527,7 +1527,9 @@ static UniValue protx_diff(const JSONRPCRequest& request, CDeterministicMNManage
|
||||
CSimplifiedMNListDiff mnListDiff;
|
||||
std::string strError;
|
||||
|
||||
if (!BuildSimplifiedMNListDiff(baseBlockHash, blockHash, mnListDiff, dmnman, *llmq_ctx.quorum_block_processor, *llmq_ctx.qman, strError, extended)) {
|
||||
if (!BuildSimplifiedMNListDiff(dmnman, chainman, *llmq_ctx.quorum_block_processor, *llmq_ctx.qman, baseBlockHash,
|
||||
blockHash, mnListDiff, strError, extended))
|
||||
{
|
||||
throw std::runtime_error(strError);
|
||||
}
|
||||
|
||||
|
@ -818,7 +818,7 @@ static RPCHelpMan quorum_rotationinfo()
|
||||
|
||||
LOCK(cs_main);
|
||||
|
||||
if (!BuildQuorumRotationInfo(cmd, quorumRotationInfoRet, *node.dmnman, chainman, *llmq_ctx.qman, *llmq_ctx.quorum_block_processor, strError)) {
|
||||
if (!BuildQuorumRotationInfo(*node.dmnman, chainman, *llmq_ctx.qman, *llmq_ctx.quorum_block_processor, cmd, quorumRotationInfoRet, strError)) {
|
||||
throw JSONRPCError(RPC_INVALID_REQUEST, strError);
|
||||
}
|
||||
|
||||
|
@ -119,7 +119,7 @@ void DashTestSetup(NodeContext& node, const CChainParams& chainparams)
|
||||
#endif // ENABLE_WALLET
|
||||
node.llmq_ctx = std::make_unique<LLMQContext>(chainstate, *node.connman, *node.dmnman, *node.evodb, *node.mn_metaman, *node.mnhf_manager, *node.sporkman, *node.mempool,
|
||||
/* mn_activeman = */ nullptr, *node.mn_sync, node.peerman, /* unit_tests = */ true, /* wipe = */ false);
|
||||
Assert(node.mnhf_manager)->ConnectManagers(node.llmq_ctx->qman.get());
|
||||
Assert(node.mnhf_manager)->ConnectManagers(node.chainman, node.llmq_ctx->qman.get());
|
||||
node.chain_helper = std::make_unique<CChainstateHelper>(*node.cpoolman, *node.dmnman, *node.mnhf_manager, *node.govman, *(node.llmq_ctx->quorum_block_processor), *node.chainman,
|
||||
chainparams.GetConsensus(), *node.mn_sync, *node.sporkman, *(node.llmq_ctx->clhandler), *(node.llmq_ctx->qman));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user