From 559bdfc6ef3b503bd4aeab83d9750cdd9f296fa1 Mon Sep 17 00:00:00 2001 From: UdjinM6 Date: Tue, 29 Jan 2019 17:57:30 +0300 Subject: [PATCH] ProcessSpecialTxsInBlock should respect fJustCheck (#2653) * ProcessSpecialTxsInBlock should respect fJustCheck Also invoke it after subsidy/payee checks * Drop fJustCheck from CQuorumBlockProcessor --- src/evo/deterministicmns.cpp | 6 +++++- src/evo/deterministicmns.h | 2 +- src/evo/specialtx.cpp | 4 ++-- src/evo/specialtx.h | 2 +- src/validation.cpp | 10 ++++++---- 5 files changed, 15 insertions(+), 9 deletions(-) diff --git a/src/evo/deterministicmns.cpp b/src/evo/deterministicmns.cpp index 3d7f26330..35281e037 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 7d05f179a..43461eb8f 100644 --- a/src/evo/deterministicmns.h +++ b/src/evo/deterministicmns.h @@ -479,7 +479,7 @@ private: 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 9e916bb45..7bd3ad8c1 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]; @@ -102,7 +102,7 @@ bool ProcessSpecialTxsInBlock(const CBlock& block, const CBlockIndex* pindex, CV 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 9eb49ea02..151b67141 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/validation.cpp b/src/validation.cpp index ae2d2e67b..7abc06fa2 100644 --- a/src/validation.cpp +++ b/src/validation.cpp @@ -2184,10 +2184,6 @@ static bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockInd int64_t nTime4 = GetTimeMicros(); nTimeVerify += nTime4 - nTime2; LogPrint("bench", " - Verify %u txins: %.2fms (%.3fms/txin) [%.2fs]\n", nInputs - 1, 0.001 * (nTime4 - nTime2), nInputs <= 1 ? 0 : 0.001 * (nTime4 - nTime2) / (nInputs-1), nTimeVerify * 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 @@ -2208,6 +2204,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)); + } + int64_t nTime5 = GetTimeMicros(); nTimeVerify += nTime5 - nTime4; LogPrint("bench", " - Payee and special txes: %.2fms [%.2fs]\n", 0.001 * (nTime4 - nTime2), nTimeVerify * 0.000001);