mirror of
https://github.com/dashpay/dash.git
synced 2024-12-25 20:12:57 +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,
|
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());
|
assert(mn_metaman.IsValid());
|
||||||
|
|
||||||
@ -105,7 +106,7 @@ PeerMsgRet CMNAuth::ProcessMessage(CNode& peer, CConnman& connman, CMasternodeMe
|
|||||||
if (Params().NetworkIDString() != CBaseChainParams::MAIN && gArgs.IsArgSet("-pushversion")) {
|
if (Params().NetworkIDString() != CBaseChainParams::MAIN && gArgs.IsArgSet("-pushversion")) {
|
||||||
nOurNodeVersion = gArgs.GetArg("-pushversion", PROTOCOL_VERSION);
|
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)};
|
const bool is_basic_scheme_active{DeploymentActiveAfter(tip, Params().GetConsensus(), Consensus::DEPLOYMENT_V19)};
|
||||||
ConstCBLSPublicKeyVersionWrapper pubKey(dmn->pdmnState->pubKeyOperator.Get(), !is_basic_scheme_active);
|
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)
|
// 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 CActiveMasternodeManager;
|
||||||
class CBlockIndex;
|
class CBlockIndex;
|
||||||
|
class CChain;
|
||||||
class CConnman;
|
class CConnman;
|
||||||
class CDataStream;
|
class CDataStream;
|
||||||
class CDeterministicMN;
|
class CDeterministicMN;
|
||||||
@ -59,7 +60,8 @@ public:
|
|||||||
* attempting to call this function regardless of sync state
|
* attempting to call this function regardless of sync state
|
||||||
*/
|
*/
|
||||||
static PeerMsgRet ProcessMessage(CNode& peer, CConnman& connman, CMasternodeMetaMan& mn_metaman, const CActiveMasternodeManager* const mn_activeman,
|
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);
|
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;
|
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) {
|
if (!tx.IsSpecialTxVersion() || tx.nType != TRANSACTION_MNHF_SIGNAL) {
|
||||||
return state.Invalid(TxValidationResult::TX_CONSENSUS, "bad-mnhf-type");
|
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");
|
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) {
|
if (!pindexQuorum) {
|
||||||
return state.Invalid(TxValidationResult::TX_CONSENSUS, "bad-mnhf-quorum-hash");
|
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;
|
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
|
// we skip the coinbase
|
||||||
for (size_t i = 1; i < block.vtx.size(); ++i) {
|
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;
|
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());
|
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)
|
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 {
|
try {
|
||||||
std::vector<uint8_t> new_signals;
|
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
|
// state is set inside extractSignals
|
||||||
return std::nullopt;
|
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)
|
bool CMNHFManager::UndoBlock(const CBlock& block, const CBlockIndex* const pindex)
|
||||||
{
|
{
|
||||||
assert(m_qman);
|
assert(m_chainman && m_qman);
|
||||||
|
|
||||||
std::vector<uint8_t> excluded_signals;
|
std::vector<uint8_t> excluded_signals;
|
||||||
BlockValidationState state;
|
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__);
|
LogPrintf("CMNHFManager::%s: failed to extract signals\n", __func__);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -354,10 +354,11 @@ void CMNHFManager::AddSignal(const CBlockIndex* const pindex, int bit)
|
|||||||
AddToCache(signals, pindex);
|
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
|
// Do not allow double-initialization
|
||||||
assert(m_qman == nullptr);
|
assert(m_chainman == nullptr && m_qman == nullptr);
|
||||||
|
m_chainman = chainman;
|
||||||
m_qman = qman;
|
m_qman = qman;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,6 +22,7 @@ class BlockValidationState;
|
|||||||
class CBlock;
|
class CBlock;
|
||||||
class CBlockIndex;
|
class CBlockIndex;
|
||||||
class CEvoDB;
|
class CEvoDB;
|
||||||
|
class ChainstateManager;
|
||||||
class TxValidationState;
|
class TxValidationState;
|
||||||
namespace llmq {
|
namespace llmq {
|
||||||
class CQuorumManager;
|
class CQuorumManager;
|
||||||
@ -100,6 +101,7 @@ class CMNHFManager : public AbstractEHFManager
|
|||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
CEvoDB& m_evoDb;
|
CEvoDB& m_evoDb;
|
||||||
|
ChainstateManager* m_chainman{nullptr};
|
||||||
llmq::CQuorumManager* m_qman{nullptr};
|
llmq::CQuorumManager* m_qman{nullptr};
|
||||||
|
|
||||||
static constexpr size_t MNHFCacheSize = 1000;
|
static constexpr size_t MNHFCacheSize = 1000;
|
||||||
@ -147,14 +149,14 @@ public:
|
|||||||
* Separated from constructor to allow LLMQContext to use CMNHFManager in read-only capacity.
|
* Separated from constructor to allow LLMQContext to use CMNHFManager in read-only capacity.
|
||||||
* Required to mutate state.
|
* 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.
|
* Reset llmq::CQuorumManager pointer.
|
||||||
*
|
*
|
||||||
* @pre Must be called before LLMQContext (containing llmq::CQuorumManager) is destroyed.
|
* @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:
|
private:
|
||||||
void AddToCache(const Signals& signals, const CBlockIndex* const pindex);
|
void AddToCache(const Signals& signals, const CBlockIndex* const pindex);
|
||||||
@ -175,6 +177,6 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
std::optional<uint8_t> extractEHFSignal(const CTransaction& tx);
|
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
|
#endif // BITCOIN_EVO_MNHFTX_H
|
||||||
|
@ -316,29 +316,29 @@ CSimplifiedMNListDiff BuildSimplifiedDiff(const CDeterministicMNList& from, cons
|
|||||||
return diffRet;
|
return diffRet;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BuildSimplifiedMNListDiff(const uint256& baseBlockHash, const uint256& blockHash, CSimplifiedMNListDiff& mnListDiffRet,
|
bool BuildSimplifiedMNListDiff(CDeterministicMNManager& dmnman, const ChainstateManager& chainman, const llmq::CQuorumBlockProcessor& qblockman,
|
||||||
CDeterministicMNManager& dmnman, const llmq::CQuorumBlockProcessor& quorum_block_processor, const llmq::CQuorumManager& qman,
|
const llmq::CQuorumManager& qman, const uint256& baseBlockHash, const uint256& blockHash,
|
||||||
std::string& errorRet, bool extended)
|
CSimplifiedMNListDiff& mnListDiffRet, std::string& errorRet, bool extended)
|
||||||
{
|
{
|
||||||
AssertLockHeld(cs_main);
|
AssertLockHeld(cs_main);
|
||||||
mnListDiffRet = CSimplifiedMNListDiff();
|
mnListDiffRet = CSimplifiedMNListDiff();
|
||||||
|
|
||||||
const CBlockIndex* baseBlockIndex = ::ChainActive().Genesis();
|
const CBlockIndex* baseBlockIndex = chainman.ActiveChain().Genesis();
|
||||||
if (!baseBlockHash.IsNull()) {
|
if (!baseBlockHash.IsNull()) {
|
||||||
baseBlockIndex = g_chainman.m_blockman.LookupBlockIndex(baseBlockHash);
|
baseBlockIndex = chainman.m_blockman.LookupBlockIndex(baseBlockHash);
|
||||||
if (!baseBlockIndex) {
|
if (!baseBlockIndex) {
|
||||||
errorRet = strprintf("block %s not found", baseBlockHash.ToString());
|
errorRet = strprintf("block %s not found", baseBlockHash.ToString());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const CBlockIndex* blockIndex = g_chainman.m_blockman.LookupBlockIndex(blockHash);
|
const CBlockIndex* blockIndex = chainman.m_blockman.LookupBlockIndex(blockHash);
|
||||||
if (!blockIndex) {
|
if (!blockIndex) {
|
||||||
errorRet = strprintf("block %s not found", blockHash.ToString());
|
errorRet = strprintf("block %s not found", blockHash.ToString());
|
||||||
return false;
|
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());
|
errorRet = strprintf("block %s and %s are not in the same chain", baseBlockHash.ToString(), blockHash.ToString());
|
||||||
return false;
|
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.
|
// null block hash was provided to get the diff from the genesis block.
|
||||||
mnListDiffRet.baseBlockHash = baseBlockHash;
|
mnListDiffRet.baseBlockHash = baseBlockHash;
|
||||||
|
|
||||||
if (!mnListDiffRet.BuildQuorumsDiff(baseBlockIndex, blockIndex, quorum_block_processor)) {
|
if (!mnListDiffRet.BuildQuorumsDiff(baseBlockIndex, blockIndex, qblockman)) {
|
||||||
errorRet = strprintf("failed to build quorums diff");
|
errorRet = strprintf("failed to build quorums diff");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -16,6 +16,7 @@ class UniValue;
|
|||||||
class CBlockIndex;
|
class CBlockIndex;
|
||||||
class CDeterministicMNList;
|
class CDeterministicMNList;
|
||||||
class CDeterministicMN;
|
class CDeterministicMN;
|
||||||
|
class ChainstateManager;
|
||||||
|
|
||||||
namespace llmq {
|
namespace llmq {
|
||||||
class CFinalCommitment;
|
class CFinalCommitment;
|
||||||
@ -170,8 +171,8 @@ public:
|
|||||||
[[nodiscard]] UniValue ToJson(bool extended = false) const;
|
[[nodiscard]] UniValue ToJson(bool extended = false) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
bool BuildSimplifiedMNListDiff(const uint256& baseBlockHash, const uint256& blockHash, CSimplifiedMNListDiff& mnListDiffRet,
|
bool BuildSimplifiedMNListDiff(CDeterministicMNManager& dmnman, const ChainstateManager& chainman, const llmq::CQuorumBlockProcessor& qblockman,
|
||||||
CDeterministicMNManager& dmnman, const llmq::CQuorumBlockProcessor& quorum_block_processor, const llmq::CQuorumManager& qman,
|
const llmq::CQuorumManager& qman, const uint256& baseBlockHash, const uint256& blockHash,
|
||||||
std::string& errorRet, bool extended = false);
|
CSimplifiedMNListDiff& mnListDiffRet, std::string& errorRet, bool extended = false);
|
||||||
|
|
||||||
#endif // BITCOIN_EVO_SIMPLIFIEDMNS_H
|
#endif // BITCOIN_EVO_SIMPLIFIEDMNS_H
|
||||||
|
@ -51,7 +51,7 @@ static bool CheckSpecialTxInner(CDeterministicMNManager& dmnman, const Chainstat
|
|||||||
if (!DeploymentActiveAfter(pindexPrev, consensusParams, Consensus::DEPLOYMENT_V20)) {
|
if (!DeploymentActiveAfter(pindexPrev, consensusParams, Consensus::DEPLOYMENT_V20)) {
|
||||||
return state.Invalid(TxValidationResult::TX_CONSENSUS, "mnhf-before-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:
|
case TRANSACTION_ASSET_LOCK:
|
||||||
if (!DeploymentActiveAfter(pindexPrev, consensusParams, Consensus::DEPLOYMENT_V20)) {
|
if (!DeploymentActiveAfter(pindexPrev, consensusParams, Consensus::DEPLOYMENT_V20)) {
|
||||||
return state.Invalid(TxValidationResult::TX_CONSENSUS, "assetlocks-before-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.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);
|
*node.mempool, node.mn_activeman.get(), *node.mn_sync, node.peerman, /* unit_tests = */ false, /* wipe = */ fReset || fReindexChainState);
|
||||||
// Enable CMNHFManager::{Process, Undo}Block
|
// 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
|
// Have to start it early to let VerifyDB check ChainLock signatures in coinbase
|
||||||
node.llmq_ctx->Start();
|
node.llmq_ctx->Start();
|
||||||
|
|
||||||
|
@ -85,9 +85,9 @@ UniValue CQuorumRotationInfo::ToJson() const
|
|||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BuildQuorumRotationInfo(const CGetQuorumRotationInfo& request, CQuorumRotationInfo& response,
|
bool BuildQuorumRotationInfo(CDeterministicMNManager& dmnman, const ChainstateManager& chainman, const CQuorumManager& qman,
|
||||||
CDeterministicMNManager& dmnman, const ChainstateManager& chainman, const CQuorumManager& qman,
|
const CQuorumBlockProcessor& qblockman, const CGetQuorumRotationInfo& request,
|
||||||
const CQuorumBlockProcessor& quorum_block_processor, std::string& errorRet)
|
CQuorumRotationInfo& response, std::string& errorRet)
|
||||||
{
|
{
|
||||||
AssertLockHeld(cs_main);
|
AssertLockHeld(cs_main);
|
||||||
|
|
||||||
@ -123,7 +123,7 @@ bool BuildQuorumRotationInfo(const CGetQuorumRotationInfo& request, CQuorumRotat
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
//Build MN list Diff always with highest baseblock
|
//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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -156,7 +156,7 @@ bool BuildQuorumRotationInfo(const CGetQuorumRotationInfo& request, CQuorumRotat
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Build MN list Diff always with highest baseblock
|
//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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -202,7 +202,7 @@ bool BuildQuorumRotationInfo(const CGetQuorumRotationInfo& request, CQuorumRotat
|
|||||||
const CBlockIndex* pWorkBlockHMinus4CIndex = pBlockHMinus4CIndex->GetAncestor(pBlockHMinus4CIndex->nHeight - workDiff);
|
const CBlockIndex* pWorkBlockHMinus4CIndex = pBlockHMinus4CIndex->GetAncestor(pBlockHMinus4CIndex->nHeight - workDiff);
|
||||||
//Checked later if extraShare is on
|
//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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -214,7 +214,7 @@ bool BuildQuorumRotationInfo(const CGetQuorumRotationInfo& request, CQuorumRotat
|
|||||||
response.quorumSnapshotAtHMinusC = std::move(snapshotHMinusC.value());
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -226,7 +226,7 @@ bool BuildQuorumRotationInfo(const CGetQuorumRotationInfo& request, CQuorumRotat
|
|||||||
response.quorumSnapshotAtHMinus2C = std::move(snapshotHMinus2C.value());
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -255,7 +255,7 @@ bool BuildQuorumRotationInfo(const CGetQuorumRotationInfo& request, CQuorumRotat
|
|||||||
}
|
}
|
||||||
|
|
||||||
CSimplifiedMNListDiff mn4c;
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -268,11 +268,11 @@ bool BuildQuorumRotationInfo(const CGetQuorumRotationInfo& request, CQuorumRotat
|
|||||||
|
|
||||||
std::set<int> snapshotHeightsNeeded;
|
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) {
|
for (const auto& obj : qdata) {
|
||||||
uint256 minedBlockHash;
|
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) {
|
if (qc == nullptr) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -311,7 +311,7 @@ bool BuildQuorumRotationInfo(const CGetQuorumRotationInfo& request, CQuorumRotat
|
|||||||
}
|
}
|
||||||
|
|
||||||
CSimplifiedMNListDiff mnhneeded;
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -207,9 +207,9 @@ public:
|
|||||||
[[nodiscard]] UniValue ToJson() const;
|
[[nodiscard]] UniValue ToJson() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
bool BuildQuorumRotationInfo(const CGetQuorumRotationInfo& request, CQuorumRotationInfo& response,
|
bool BuildQuorumRotationInfo(CDeterministicMNManager& dmnman, const ChainstateManager& chainman, const CQuorumManager& qman,
|
||||||
CDeterministicMNManager& dmnman, const ChainstateManager& chainman, const CQuorumManager& qman,
|
const CQuorumBlockProcessor& qblockman, const CGetQuorumRotationInfo& request,
|
||||||
const CQuorumBlockProcessor& quorumBlockProcessor, std::string& errorRet);
|
CQuorumRotationInfo& response, std::string& errorRet);
|
||||||
uint256 GetLastBaseBlockHash(Span<const CBlockIndex*> baseBlockIndexes, const CBlockIndex* blockIndex);
|
uint256 GetLastBaseBlockHash(Span<const CBlockIndex*> baseBlockIndexes, const CBlockIndex* blockIndex);
|
||||||
|
|
||||||
class CQuorumSnapshotManager
|
class CQuorumSnapshotManager
|
||||||
|
@ -4803,7 +4803,9 @@ void PeerManagerImpl::ProcessMessage(
|
|||||||
|
|
||||||
CSimplifiedMNListDiff mnListDiff;
|
CSimplifiedMNListDiff mnListDiff;
|
||||||
std::string strError;
|
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));
|
m_connman.PushMessage(&pfrom, msgMaker.Make(NetMsgType::MNLISTDIFF, mnListDiff));
|
||||||
} else {
|
} else {
|
||||||
strError = strprintf("getmnlistdiff failed for baseBlockHash=%s, blockHash=%s. error=%s", cmd.baseBlockHash.ToString(), cmd.blockHash.ToString(), strError);
|
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;
|
llmq::CQuorumRotationInfo quorumRotationInfoRet;
|
||||||
std::string strError;
|
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));
|
m_connman.PushMessage(&pfrom, msgMaker.Make(NetMsgType::QUORUMROTATIONINFO, quorumRotationInfoRet));
|
||||||
} else {
|
} else {
|
||||||
strError = strprintf("getquorumrotationinfo failed for size(baseBlockHashes)=%d, blockRequestHash=%s. error=%s", cmd.baseBlockHashes.size(), cmd.blockRequestHash.ToString(), strError);
|
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);
|
ProcessPeerMsgRet(m_sporkman.ProcessMessage(pfrom, m_connman, *this, msg_type, vRecv), pfrom);
|
||||||
m_mn_sync.ProcessMessage(pfrom, msg_type, vRecv);
|
m_mn_sync.ProcessMessage(pfrom, msg_type, vRecv);
|
||||||
ProcessPeerMsgRet(m_govman.ProcessMessage(pfrom, m_connman, *this, msg_type, vRecv), pfrom);
|
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->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->qdkgsman->ProcessMessage(pfrom, this, is_masternode, msg_type, vRecv), pfrom);
|
||||||
ProcessPeerMsgRet(m_llmq_ctx->qman->ProcessMessage(pfrom, 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;
|
CSimplifiedMNListDiff mnListDiff;
|
||||||
std::string strError;
|
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);
|
throw std::runtime_error(strError);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -818,7 +818,7 @@ static RPCHelpMan quorum_rotationinfo()
|
|||||||
|
|
||||||
LOCK(cs_main);
|
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);
|
throw JSONRPCError(RPC_INVALID_REQUEST, strError);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -119,7 +119,7 @@ void DashTestSetup(NodeContext& node, const CChainParams& chainparams)
|
|||||||
#endif // ENABLE_WALLET
|
#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,
|
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);
|
/* 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,
|
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));
|
chainparams.GetConsensus(), *node.mn_sync, *node.sporkman, *(node.llmq_ctx->clhandler), *(node.llmq_ctx->qman));
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user