From c7d96194d6edb348febaea95b829032a504168b8 Mon Sep 17 00:00:00 2001 From: DeckerSU Date: Thu, 19 Mar 2020 01:55:56 +0300 Subject: [PATCH] [test] proper removing of txes that violates interest validation from mempool In CreateNewBlock of miner https://github.com/KomodoPlatform/komodo/blob/master/src/miner.cpp#L331 we have a condition that prevents miners to include certain txes in block if tx violates komodo_validate_interest check. so, if such txes will exist in mempool and in some reason they was not miner earlier, if they have nExpiryHeight = 0 - they NEVER will be included in block by miners. Also, code in CTxMemPool::removeExpired that should remove such txes from mempool didn't do it due to mistake. As a result these txes stucks in mempool. No one can mine it, bcz no one can include it in block, and no one get success to remove it from mempool. Look on old code: ``` (ASSETCHAINS_SYMBOL[0] == 0 && tipindex != 0 && komodo_validate_interest(...) ) < 0 ``` But should be: ``` (ASSETCHAINS_SYMBOL[0] == 0 && tipindex != 0 && komodo_validate_interest(...) < 0 ) ``` Bcz we should compare with 0 result of komodo_validate_interest, but we had different behaviour, due to typo. --- src/txmempool.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/txmempool.cpp b/src/txmempool.cpp index 307be723e..ca0ed7f51 100644 --- a/src/txmempool.cpp +++ b/src/txmempool.cpp @@ -523,8 +523,12 @@ std::vector CTxMemPool::removeExpired(unsigned int nBlockHeight) { const CTransaction& tx = it->GetTx(); tipindex = chainActive.LastTip(); - if (IsExpiredTx(tx, nBlockHeight) || (ASSETCHAINS_SYMBOL[0] == 0 && tipindex != 0 && komodo_validate_interest(tx,tipindex->GetHeight()+1,tipindex->GetMedianTimePast() + 777,0)) < 0) + + bool fInterestNotValidated = ASSETCHAINS_SYMBOL[0] == 0 && tipindex != 0 && komodo_validate_interest(tx,tipindex->GetHeight()+1,tipindex->GetMedianTimePast() + 777,0) < 0; + if (IsExpiredTx(tx, nBlockHeight) || fInterestNotValidated) { + if (fInterestNotValidated && tipindex != 0) + LogPrintf("Removing interest violate txid.%s nHeight.%d nTime.%u vs locktime.%u\n",tx.GetHash().ToString(),tipindex->GetHeight()+1,tipindex->GetMedianTimePast() + 777,tx.nLockTime); transactionsToRemove.push_back(tx); } }