diff --git a/src/test/mempool_tests.cpp b/src/test/mempool_tests.cpp index dbf75b2c3d..e4ffbd9edb 100644 --- a/src/test/mempool_tests.cpp +++ b/src/test/mempool_tests.cpp @@ -390,8 +390,7 @@ BOOST_AUTO_TEST_CASE(MempoolAncestorIndexingTest) /* after tx6 is mined, tx7 should move up in the sort */ std::vector vtx; vtx.push_back(MakeTransactionRef(tx6)); - std::set> setPeginsSpentDummy; - pool.removeForBlock(vtx, 1, setPeginsSpentDummy); + pool.removeForBlock(vtx, 1); sortedOrder.erase(sortedOrder.begin()+1); // Ties are broken by hash @@ -550,8 +549,7 @@ BOOST_AUTO_TEST_CASE(MempoolSizeLimitTest) SetMockTime(42 + CTxMemPool::ROLLING_FEE_HALFLIFE); BOOST_CHECK_EQUAL(pool.GetMinFee(1).GetFeePerK(), maxFeeRateRemoved.GetFeePerK() + 1000); // ... we should keep the same min fee until we get a block - std::set> setPeginsSpentDummy; - pool.removeForBlock(vtx, 1, setPeginsSpentDummy); + pool.removeForBlock(vtx, 1); SetMockTime(42 + 2*CTxMemPool::ROLLING_FEE_HALFLIFE); BOOST_CHECK_EQUAL(pool.GetMinFee(1).GetFeePerK(), llround((maxFeeRateRemoved.GetFeePerK() + 1000)/2.0)); // ... then feerate should drop 1/2 each halflife diff --git a/src/test/policyestimator_tests.cpp b/src/test/policyestimator_tests.cpp index ee8d8f8b26..7b274a1658 100644 --- a/src/test/policyestimator_tests.cpp +++ b/src/test/policyestimator_tests.cpp @@ -23,7 +23,6 @@ BOOST_AUTO_TEST_CASE(BlockPolicyEstimates) CAmount basefee(2000); CAmount deltaFee(100); std::vector feeV; - std::set> setPeginsSpentDummy; // Populate vectors of increasing fees for (int j = 0; j < 10; j++) { @@ -75,7 +74,7 @@ BOOST_AUTO_TEST_CASE(BlockPolicyEstimates) txHashes[9-h].pop_back(); } } - mpool.removeForBlock(block, ++blocknum, setPeginsSpentDummy); + mpool.removeForBlock(block, ++blocknum); block.clear(); // Check after just a few txs that combining buckets works as expected if (blocknum == 3) { @@ -114,7 +113,7 @@ BOOST_AUTO_TEST_CASE(BlockPolicyEstimates) // Mine 50 more blocks with no transactions happening, estimates shouldn't change // We haven't decayed the moving average enough so we still have enough data points in every bucket while (blocknum < 250) - mpool.removeForBlock(block, ++blocknum, setPeginsSpentDummy); + mpool.removeForBlock(block, ++blocknum); BOOST_CHECK(feeEst.estimateFee(1) == CFeeRate(0)); for (int i = 2; i < 10;i++) { @@ -134,7 +133,7 @@ BOOST_AUTO_TEST_CASE(BlockPolicyEstimates) txHashes[j].push_back(hash); } } - mpool.removeForBlock(block, ++blocknum, setPeginsSpentDummy); + mpool.removeForBlock(block, ++blocknum); } for (int i = 1; i < 10;i++) { @@ -151,7 +150,7 @@ BOOST_AUTO_TEST_CASE(BlockPolicyEstimates) txHashes[j].pop_back(); } } - mpool.removeForBlock(block, 266, setPeginsSpentDummy); + mpool.removeForBlock(block, 266); block.clear(); BOOST_CHECK(feeEst.estimateFee(1) == CFeeRate(0)); for (int i = 2; i < 10;i++) { @@ -172,7 +171,7 @@ BOOST_AUTO_TEST_CASE(BlockPolicyEstimates) } } - mpool.removeForBlock(block, ++blocknum, setPeginsSpentDummy); + mpool.removeForBlock(block, ++blocknum); block.clear(); } BOOST_CHECK(feeEst.estimateFee(1) == CFeeRate(0)); diff --git a/src/txmempool.cpp b/src/txmempool.cpp index 6182777edb..60ae8bd855 100644 --- a/src/txmempool.cpp +++ b/src/txmempool.cpp @@ -403,13 +403,6 @@ void CTxMemPool::addUnchecked(const CTxMemPoolEntry &entry, setEntries &setAnces vTxHashes.emplace_back(tx.GetWitnessHash(), newit); newit->vTxHashesIdx = vTxHashes.size() - 1; - - // ELEMENTS: - typedef std::pair PeginPair; - for(const PeginPair& it : entry.setPeginsSpent) { - std::pair, uint256>::iterator, bool> ret = mapPeginsSpentToTxid.insert(std::make_pair(it, tx.GetHash())); - assert(ret.second); - } } void CTxMemPool::removeUnchecked(txiter it, MemPoolRemovalReason reason) @@ -419,12 +412,6 @@ void CTxMemPool::removeUnchecked(txiter it, MemPoolRemovalReason reason) for (const CTxIn& txin : it->GetTx().vin) mapNextTx.erase(txin.prevout); - // ELEMENTS: - typedef std::pair PeginPair; - for (const PeginPair& it2 : it->setPeginsSpent) { - mapPeginsSpentToTxid.erase(it2); - } - if (vTxHashes.size() > 1) { vTxHashes[it->vTxHashesIdx] = std::move(vTxHashes.back()); vTxHashes[it->vTxHashesIdx].second->vTxHashesIdx = it->vTxHashesIdx; @@ -561,7 +548,7 @@ void CTxMemPool::removeConflicts(const CTransaction &tx) /** * Called when a block is connected. Removes from mempool and updates the miner fee estimator. */ -void CTxMemPool::removeForBlock(const std::vector& vtx, unsigned int nBlockHeight, const std::set>& setPeginsSpent, bool pak_transition) +void CTxMemPool::removeForBlock(const std::vector& vtx, unsigned int nBlockHeight, bool pak_transition) { LOCK(cs); std::vector entries; @@ -587,22 +574,6 @@ void CTxMemPool::removeForBlock(const std::vector& vtx, unsigne ClearPrioritisation(tx->GetHash()); } - // ELEMENTS: - // Eject any conflicting pegins - for (std::set >::const_iterator it = setPeginsSpent.begin(); it != setPeginsSpent.end(); it++) { - std::map, uint256>::const_iterator it2 = mapPeginsSpentToTxid.find(*it); - if (it2 != mapPeginsSpentToTxid.end()) { - uint256 tx_id = it2->second; - txiter txit = mapTx.find(tx_id); - assert(txit != mapTx.end()); - const CTransaction& tx = txit->GetTx(); - setEntries stage; - stage.insert(txit); - RemoveStaged(stage, true); - removeRecursive(tx, MemPoolRemovalReason::CONFLICT); - ClearPrioritisation(tx_id); - } - } // Eject any newly-invalid peg-outs based on changing block commitment const CChainParams& chainparams = Params(); if (pak_transition && chainparams.GetEnforcePak()) { @@ -786,10 +757,6 @@ void CTxMemPool::check(const CCoinsViewCache *pcoins) const for (std::set >::const_iterator it = setGlobalPeginsSpent.begin(); it != setGlobalPeginsSpent.end(); it++) { assert(!pcoins->IsPeginSpent(*it)); } - for (std::map, uint256>::const_iterator it = mapPeginsSpentToTxid.begin(); it != mapPeginsSpentToTxid.end(); it++) { - assert(setGlobalPeginsSpent.erase(it->first)); - } - assert(setGlobalPeginsSpent.size() == 0); // END ELEMENTS // @@ -988,7 +955,7 @@ bool CCoinsViewMemPool::GetCoin(const COutPoint &outpoint, Coin &coin) const { // ELEMENTS: bool CCoinsViewMemPool::IsPeginSpent(const std::pair &outpoint) const { - return mempool.mapPeginsSpentToTxid.count(outpoint) || base->IsPeginSpent(outpoint); + return base->IsPeginSpent(outpoint); } size_t CTxMemPool::DynamicMemoryUsage() const { diff --git a/src/txmempool.h b/src/txmempool.h index 58a2e51d10..5b755066c3 100644 --- a/src/txmempool.h +++ b/src/txmempool.h @@ -541,8 +541,6 @@ public: const setEntries & GetMemPoolParents(txiter entry) const EXCLUSIVE_LOCKS_REQUIRED(cs); const setEntries & GetMemPoolChildren(txiter entry) const EXCLUSIVE_LOCKS_REQUIRED(cs); uint64_t CalculateDescendantMaximum(txiter entry) const EXCLUSIVE_LOCKS_REQUIRED(cs); - // ELEMENTS: - std::map, uint256> mapPeginsSpentToTxid; private: typedef std::map cacheMap; @@ -590,7 +588,7 @@ public: void removeForReorg(const CCoinsViewCache *pcoins, unsigned int nMemPoolHeight, int flags) EXCLUSIVE_LOCKS_REQUIRED(cs_main); void removeConflicts(const CTransaction &tx) EXCLUSIVE_LOCKS_REQUIRED(cs); void removeForBlock(const std::vector& vtx, unsigned int nBlockHeight, - const std::set>& setPeginsSpent, bool pak_transition=false); + bool pak_transition=false); void clear(); void _clear() EXCLUSIVE_LOCKS_REQUIRED(cs); //lock free diff --git a/src/validation.cpp b/src/validation.cpp index ccb057e717..b0fd88fce9 100644 --- a/src/validation.cpp +++ b/src/validation.cpp @@ -2646,7 +2646,7 @@ bool CChainState::ConnectTip(CValidationState& state, const CChainParams& chainp // ELEMENTS: We also eject now-invalid peg-outs based on block transition if not config list set // If config is set, this means all peg-outs have been filtered for that list already and other // functionaries aren't matching your list. Operator should restart with no list or new matching list. - mempool.removeForBlock(blockConnecting.vtx, pindexNew->nHeight, setPeginsSpent, (paklist && !g_paklist_config)); + mempool.removeForBlock(blockConnecting.vtx, pindexNew->nHeight, (paklist && !g_paklist_config)); disconnectpool.removeForBlock(blockConnecting.vtx); // Update chainActive & related variables. chainActive.SetTip(pindexNew);