diff --git a/src/evo/deterministicmns.cpp b/src/evo/deterministicmns.cpp index 52e70d48ffb824..5f780a8120a369 100644 --- a/src/evo/deterministicmns.cpp +++ b/src/evo/deterministicmns.cpp @@ -444,7 +444,7 @@ CDeterministicMNManager::CDeterministicMNManager(CEvoDB& _evoDb) : { } -bool CDeterministicMNManager::ProcessBlock(const CBlock& block, const CBlockIndex* pindex, CValidationState& _state) +bool CDeterministicMNManager::ProcessBlock(const CBlock& block, const CBlockIndex* pindex, CValidationState& _state, bool fJustCheck) { CDeterministicMNList oldList, newList; CDeterministicMNListDiff diff; @@ -458,6 +458,10 @@ bool CDeterministicMNManager::ProcessBlock(const CBlock& block, const CBlockInde return false; } + if (fJustCheck) { + return true; + } + if (newList.GetHeight() == -1) { newList.SetHeight(nHeight); } diff --git a/src/evo/deterministicmns.h b/src/evo/deterministicmns.h index 6a8469b1171934..868a774551f39c 100644 --- a/src/evo/deterministicmns.h +++ b/src/evo/deterministicmns.h @@ -479,7 +479,7 @@ class CDeterministicMNManager public: CDeterministicMNManager(CEvoDB& _evoDb); - bool ProcessBlock(const CBlock& block, const CBlockIndex* pindex, CValidationState& state); + bool ProcessBlock(const CBlock& block, const CBlockIndex* pindex, CValidationState& state, bool fJustCheck); bool UndoBlock(const CBlock& block, const CBlockIndex* pindex); void UpdatedBlockTip(const CBlockIndex* pindex); diff --git a/src/evo/specialtx.cpp b/src/evo/specialtx.cpp index 9e916bb45698f3..b73b59fc9cdbba 100644 --- a/src/evo/specialtx.cpp +++ b/src/evo/specialtx.cpp @@ -86,7 +86,7 @@ bool UndoSpecialTx(const CTransaction& tx, const CBlockIndex* pindex) return false; } -bool ProcessSpecialTxsInBlock(const CBlock& block, const CBlockIndex* pindex, CValidationState& state) +bool ProcessSpecialTxsInBlock(const CBlock& block, const CBlockIndex* pindex, CValidationState& state, bool fJustCheck) { for (int i = 0; i < (int)block.vtx.size(); i++) { const CTransaction& tx = *block.vtx[i]; @@ -98,11 +98,11 @@ bool ProcessSpecialTxsInBlock(const CBlock& block, const CBlockIndex* pindex, CV } } - if (!llmq::quorumBlockProcessor->ProcessBlock(block, pindex, state)) { + if (!llmq::quorumBlockProcessor->ProcessBlock(block, pindex, state, fJustCheck)) { return false; } - if (!deterministicMNManager->ProcessBlock(block, pindex, state)) { + if (!deterministicMNManager->ProcessBlock(block, pindex, state, fJustCheck)) { return false; } diff --git a/src/evo/specialtx.h b/src/evo/specialtx.h index 9eb49ea020177d..151b67141082ca 100644 --- a/src/evo/specialtx.h +++ b/src/evo/specialtx.h @@ -14,7 +14,7 @@ class CBlockIndex; class CValidationState; bool CheckSpecialTx(const CTransaction& tx, const CBlockIndex* pindexPrev, CValidationState& state); -bool ProcessSpecialTxsInBlock(const CBlock& block, const CBlockIndex* pindex, CValidationState& state); +bool ProcessSpecialTxsInBlock(const CBlock& block, const CBlockIndex* pindex, CValidationState& state, bool fJustCheck); bool UndoSpecialTxsInBlock(const CBlock& block, const CBlockIndex* pindex); template diff --git a/src/llmq/quorums_blockprocessor.cpp b/src/llmq/quorums_blockprocessor.cpp index 639a3f6a36d74b..2fbdaf37655815 100644 --- a/src/llmq/quorums_blockprocessor.cpp +++ b/src/llmq/quorums_blockprocessor.cpp @@ -106,7 +106,7 @@ void CQuorumBlockProcessor::ProcessMessage(CNode* pfrom, const std::string& strC } } -bool CQuorumBlockProcessor::ProcessBlock(const CBlock& block, const CBlockIndex* pindex, CValidationState& state) +bool CQuorumBlockProcessor::ProcessBlock(const CBlock& block, const CBlockIndex* pindex, CValidationState& state, bool fJustCheck) { AssertLockHeld(cs_main); @@ -144,14 +144,14 @@ bool CQuorumBlockProcessor::ProcessBlock(const CBlock& block, const CBlockIndex* for (auto& p : qcs) { auto& qc = p.second; - if (!ProcessCommitment(pindex, qc, state)) { + if (!ProcessCommitment(pindex, qc, state, fJustCheck)) { return false; } } return true; } -bool CQuorumBlockProcessor::ProcessCommitment(const CBlockIndex* pindex, const CFinalCommitment& qc, CValidationState& state) +bool CQuorumBlockProcessor::ProcessCommitment(const CBlockIndex* pindex, const CFinalCommitment& qc, CValidationState& state, bool fJustCheck) { auto& params = Params().GetConsensus().llmqs.at((Consensus::LLMQType)qc.llmqType); @@ -186,8 +186,10 @@ bool CQuorumBlockProcessor::ProcessCommitment(const CBlockIndex* pindex, const C return state.DoS(100, false, REJECT_INVALID, "bad-qc-invalid"); } - // Store commitment in DB - evoDb.Write(std::make_pair(DB_MINED_COMMITMENT, std::make_pair((uint8_t)params.type, quorumHash)), qc); + if (!fJustCheck) { + // Store commitment in DB + evoDb.Write(std::make_pair(DB_MINED_COMMITMENT, std::make_pair((uint8_t)params.type, quorumHash)), qc); + } LogPrintf("CQuorumBlockProcessor::%s -- processed commitment from block. type=%d, quorumHash=%s, signers=%s, validMembers=%d, quorumPublicKey=%s\n", __func__, qc.llmqType, quorumHash.ToString(), qc.CountSigners(), qc.CountValidMembers(), qc.quorumPublicKey.ToString()); diff --git a/src/llmq/quorums_blockprocessor.h b/src/llmq/quorums_blockprocessor.h index ac97687644ba56..3379a5a9432f6c 100644 --- a/src/llmq/quorums_blockprocessor.h +++ b/src/llmq/quorums_blockprocessor.h @@ -34,7 +34,7 @@ class CQuorumBlockProcessor void ProcessMessage(CNode* pfrom, const std::string& strCommand, CDataStream& vRecv, CConnman& connman); - bool ProcessBlock(const CBlock& block, const CBlockIndex* pindex, CValidationState& state); + bool ProcessBlock(const CBlock& block, const CBlockIndex* pindex, CValidationState& state, bool fJustCheck); bool UndoBlock(const CBlock& block, const CBlockIndex* pindex); void AddMinableCommitment(const CFinalCommitment& fqc); @@ -48,7 +48,7 @@ class CQuorumBlockProcessor private: bool GetCommitmentsFromBlock(const CBlock& block, const CBlockIndex* pindexPrev, std::map& ret, CValidationState& state); - bool ProcessCommitment(const CBlockIndex* pindex, const CFinalCommitment& qc, CValidationState& state); + bool ProcessCommitment(const CBlockIndex* pindex, const CFinalCommitment& qc, CValidationState& state, bool fJustCheck); bool IsMiningPhase(Consensus::LLMQType llmqType, int nHeight); bool IsCommitmentRequired(Consensus::LLMQType llmqType, int nHeight); uint256 GetQuorumBlockHash(Consensus::LLMQType llmqType, int nHeight); diff --git a/src/validation.cpp b/src/validation.cpp index d78ed1a0e1d32a..9298b0bcc00424 100644 --- a/src/validation.cpp +++ b/src/validation.cpp @@ -2179,11 +2179,6 @@ static bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockInd int64_t nTime3 = GetTimeMicros(); nTimeConnect += nTime3 - nTime2; LogPrint("bench", " - Connect %u transactions: %.2fms (%.3fms/tx, %.3fms/txin) [%.2fs]\n", (unsigned)block.vtx.size(), 0.001 * (nTime3 - nTime2), 0.001 * (nTime3 - nTime2) / block.vtx.size(), nInputs <= 1 ? 0 : 0.001 * (nTime3 - nTime2) / (nInputs-1), nTimeConnect * 0.000001); - if (!ProcessSpecialTxsInBlock(block, pindex, state)) { - return error("ConnectBlock(): ProcessSpecialTxsInBlock for block %s failed with %s", - pindex->GetBlockHash().ToString(), FormatStateMessage(state)); - } - // DASH : MODIFIED TO CHECK MASTERNODE PAYMENTS AND SUPERBLOCKS // It's possible that we simply don't have enough data and this could fail @@ -2203,6 +2198,12 @@ static bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockInd return state.DoS(0, error("ConnectBlock(DASH): couldn't find masternode or superblock payments"), REJECT_INVALID, "bad-cb-payee"); } + + if (!ProcessSpecialTxsInBlock(block, pindex, state, fJustCheck)) { + return error("ConnectBlock(DASH): ProcessSpecialTxsInBlock for block %s failed with %s", + pindex->GetBlockHash().ToString(), FormatStateMessage(state)); + } + // END DASH if (!control.Wait())