Skip to content

Commit 619b438

Browse files
committed
Merge branch 'master' into catchup
2 parents 45c06d2 + e1bf441 commit 619b438

File tree

5 files changed

+11
-49
lines changed

5 files changed

+11
-49
lines changed

src/test/mempool_tests.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -390,8 +390,7 @@ BOOST_AUTO_TEST_CASE(MempoolAncestorIndexingTest)
390390
/* after tx6 is mined, tx7 should move up in the sort */
391391
std::vector<CTransactionRef> vtx;
392392
vtx.push_back(MakeTransactionRef(tx6));
393-
std::set<std::pair<uint256, COutPoint>> setPeginsSpentDummy;
394-
pool.removeForBlock(vtx, 1, setPeginsSpentDummy);
393+
pool.removeForBlock(vtx, 1);
395394

396395
sortedOrder.erase(sortedOrder.begin()+1);
397396
// Ties are broken by hash
@@ -550,8 +549,7 @@ BOOST_AUTO_TEST_CASE(MempoolSizeLimitTest)
550549
SetMockTime(42 + CTxMemPool::ROLLING_FEE_HALFLIFE);
551550
BOOST_CHECK_EQUAL(pool.GetMinFee(1).GetFeePerK(), maxFeeRateRemoved.GetFeePerK() + 1000);
552551
// ... we should keep the same min fee until we get a block
553-
std::set<std::pair<uint256, COutPoint>> setPeginsSpentDummy;
554-
pool.removeForBlock(vtx, 1, setPeginsSpentDummy);
552+
pool.removeForBlock(vtx, 1);
555553
SetMockTime(42 + 2*CTxMemPool::ROLLING_FEE_HALFLIFE);
556554
BOOST_CHECK_EQUAL(pool.GetMinFee(1).GetFeePerK(), llround((maxFeeRateRemoved.GetFeePerK() + 1000)/2.0));
557555
// ... then feerate should drop 1/2 each halflife

src/test/policyestimator_tests.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ BOOST_AUTO_TEST_CASE(BlockPolicyEstimates)
2323
CAmount basefee(2000);
2424
CAmount deltaFee(100);
2525
std::vector<CAmount> feeV;
26-
std::set<std::pair<uint256, COutPoint>> setPeginsSpentDummy;
2726

2827
// Populate vectors of increasing fees
2928
for (int j = 0; j < 10; j++) {
@@ -75,7 +74,7 @@ BOOST_AUTO_TEST_CASE(BlockPolicyEstimates)
7574
txHashes[9-h].pop_back();
7675
}
7776
}
78-
mpool.removeForBlock(block, ++blocknum, setPeginsSpentDummy);
77+
mpool.removeForBlock(block, ++blocknum);
7978
block.clear();
8079
// Check after just a few txs that combining buckets works as expected
8180
if (blocknum == 3) {
@@ -114,7 +113,7 @@ BOOST_AUTO_TEST_CASE(BlockPolicyEstimates)
114113
// Mine 50 more blocks with no transactions happening, estimates shouldn't change
115114
// We haven't decayed the moving average enough so we still have enough data points in every bucket
116115
while (blocknum < 250)
117-
mpool.removeForBlock(block, ++blocknum, setPeginsSpentDummy);
116+
mpool.removeForBlock(block, ++blocknum);
118117

119118
BOOST_CHECK(feeEst.estimateFee(1) == CFeeRate(0));
120119
for (int i = 2; i < 10;i++) {
@@ -134,7 +133,7 @@ BOOST_AUTO_TEST_CASE(BlockPolicyEstimates)
134133
txHashes[j].push_back(hash);
135134
}
136135
}
137-
mpool.removeForBlock(block, ++blocknum, setPeginsSpentDummy);
136+
mpool.removeForBlock(block, ++blocknum);
138137
}
139138

140139
for (int i = 1; i < 10;i++) {
@@ -151,7 +150,7 @@ BOOST_AUTO_TEST_CASE(BlockPolicyEstimates)
151150
txHashes[j].pop_back();
152151
}
153152
}
154-
mpool.removeForBlock(block, 266, setPeginsSpentDummy);
153+
mpool.removeForBlock(block, 266);
155154
block.clear();
156155
BOOST_CHECK(feeEst.estimateFee(1) == CFeeRate(0));
157156
for (int i = 2; i < 10;i++) {
@@ -172,7 +171,7 @@ BOOST_AUTO_TEST_CASE(BlockPolicyEstimates)
172171

173172
}
174173
}
175-
mpool.removeForBlock(block, ++blocknum, setPeginsSpentDummy);
174+
mpool.removeForBlock(block, ++blocknum);
176175
block.clear();
177176
}
178177
BOOST_CHECK(feeEst.estimateFee(1) == CFeeRate(0));

src/txmempool.cpp

Lines changed: 2 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -403,13 +403,6 @@ void CTxMemPool::addUnchecked(const CTxMemPoolEntry &entry, setEntries &setAnces
403403

404404
vTxHashes.emplace_back(tx.GetWitnessHash(), newit);
405405
newit->vTxHashesIdx = vTxHashes.size() - 1;
406-
407-
// ELEMENTS:
408-
typedef std::pair<uint256, COutPoint> PeginPair;
409-
for(const PeginPair& it : entry.setPeginsSpent) {
410-
std::pair<std::map<std::pair<uint256, COutPoint>, uint256>::iterator, bool> ret = mapPeginsSpentToTxid.insert(std::make_pair(it, tx.GetHash()));
411-
assert(ret.second);
412-
}
413406
}
414407

415408
void CTxMemPool::removeUnchecked(txiter it, MemPoolRemovalReason reason)
@@ -419,12 +412,6 @@ void CTxMemPool::removeUnchecked(txiter it, MemPoolRemovalReason reason)
419412
for (const CTxIn& txin : it->GetTx().vin)
420413
mapNextTx.erase(txin.prevout);
421414

422-
// ELEMENTS:
423-
typedef std::pair<uint256, COutPoint> PeginPair;
424-
for (const PeginPair& it2 : it->setPeginsSpent) {
425-
mapPeginsSpentToTxid.erase(it2);
426-
}
427-
428415
if (vTxHashes.size() > 1) {
429416
vTxHashes[it->vTxHashesIdx] = std::move(vTxHashes.back());
430417
vTxHashes[it->vTxHashesIdx].second->vTxHashesIdx = it->vTxHashesIdx;
@@ -561,7 +548,7 @@ void CTxMemPool::removeConflicts(const CTransaction &tx)
561548
/**
562549
* Called when a block is connected. Removes from mempool and updates the miner fee estimator.
563550
*/
564-
void CTxMemPool::removeForBlock(const std::vector<CTransactionRef>& vtx, unsigned int nBlockHeight, const std::set<std::pair<uint256, COutPoint>>& setPeginsSpent, bool pak_transition)
551+
void CTxMemPool::removeForBlock(const std::vector<CTransactionRef>& vtx, unsigned int nBlockHeight, bool pak_transition)
565552
{
566553
LOCK(cs);
567554
std::vector<const CTxMemPoolEntry*> entries;
@@ -587,22 +574,6 @@ void CTxMemPool::removeForBlock(const std::vector<CTransactionRef>& vtx, unsigne
587574
ClearPrioritisation(tx->GetHash());
588575
}
589576

590-
// ELEMENTS:
591-
// Eject any conflicting pegins
592-
for (std::set<std::pair<uint256, COutPoint> >::const_iterator it = setPeginsSpent.begin(); it != setPeginsSpent.end(); it++) {
593-
std::map<std::pair<uint256, COutPoint>, uint256>::const_iterator it2 = mapPeginsSpentToTxid.find(*it);
594-
if (it2 != mapPeginsSpentToTxid.end()) {
595-
uint256 tx_id = it2->second;
596-
txiter txit = mapTx.find(tx_id);
597-
assert(txit != mapTx.end());
598-
const CTransaction& tx = txit->GetTx();
599-
setEntries stage;
600-
stage.insert(txit);
601-
RemoveStaged(stage, true);
602-
removeRecursive(tx, MemPoolRemovalReason::CONFLICT);
603-
ClearPrioritisation(tx_id);
604-
}
605-
}
606577
// Eject any newly-invalid peg-outs based on changing block commitment
607578
const CChainParams& chainparams = Params();
608579
if (pak_transition && chainparams.GetEnforcePak()) {
@@ -786,10 +757,6 @@ void CTxMemPool::check(const CCoinsViewCache *pcoins) const
786757
for (std::set<std::pair<uint256, COutPoint> >::const_iterator it = setGlobalPeginsSpent.begin(); it != setGlobalPeginsSpent.end(); it++) {
787758
assert(!pcoins->IsPeginSpent(*it));
788759
}
789-
for (std::map<std::pair<uint256, COutPoint>, uint256>::const_iterator it = mapPeginsSpentToTxid.begin(); it != mapPeginsSpentToTxid.end(); it++) {
790-
assert(setGlobalPeginsSpent.erase(it->first));
791-
}
792-
assert(setGlobalPeginsSpent.size() == 0);
793760
// END ELEMENTS
794761
//
795762

@@ -988,7 +955,7 @@ bool CCoinsViewMemPool::GetCoin(const COutPoint &outpoint, Coin &coin) const {
988955

989956
// ELEMENTS:
990957
bool CCoinsViewMemPool::IsPeginSpent(const std::pair<uint256, COutPoint> &outpoint) const {
991-
return mempool.mapPeginsSpentToTxid.count(outpoint) || base->IsPeginSpent(outpoint);
958+
return base->IsPeginSpent(outpoint);
992959
}
993960

994961
size_t CTxMemPool::DynamicMemoryUsage() const {

src/txmempool.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -541,8 +541,6 @@ class CTxMemPool
541541
const setEntries & GetMemPoolParents(txiter entry) const EXCLUSIVE_LOCKS_REQUIRED(cs);
542542
const setEntries & GetMemPoolChildren(txiter entry) const EXCLUSIVE_LOCKS_REQUIRED(cs);
543543
uint64_t CalculateDescendantMaximum(txiter entry) const EXCLUSIVE_LOCKS_REQUIRED(cs);
544-
// ELEMENTS:
545-
std::map<std::pair<uint256, COutPoint>, uint256> mapPeginsSpentToTxid;
546544
private:
547545
typedef std::map<txiter, setEntries, CompareIteratorByHash> cacheMap;
548546

@@ -590,7 +588,7 @@ class CTxMemPool
590588
void removeForReorg(const CCoinsViewCache *pcoins, unsigned int nMemPoolHeight, int flags) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
591589
void removeConflicts(const CTransaction &tx) EXCLUSIVE_LOCKS_REQUIRED(cs);
592590
void removeForBlock(const std::vector<CTransactionRef>& vtx, unsigned int nBlockHeight,
593-
const std::set<std::pair<uint256, COutPoint>>& setPeginsSpent, bool pak_transition=false);
591+
bool pak_transition=false);
594592

595593
void clear();
596594
void _clear() EXCLUSIVE_LOCKS_REQUIRED(cs); //lock free

src/validation.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2646,7 +2646,7 @@ bool CChainState::ConnectTip(CValidationState& state, const CChainParams& chainp
26462646
// ELEMENTS: We also eject now-invalid peg-outs based on block transition if not config list set
26472647
// If config is set, this means all peg-outs have been filtered for that list already and other
26482648
// functionaries aren't matching your list. Operator should restart with no list or new matching list.
2649-
mempool.removeForBlock(blockConnecting.vtx, pindexNew->nHeight, setPeginsSpent, (paklist && !g_paklist_config));
2649+
mempool.removeForBlock(blockConnecting.vtx, pindexNew->nHeight, (paklist && !g_paklist_config));
26502650
disconnectpool.removeForBlock(blockConnecting.vtx);
26512651
// Update chainActive & related variables.
26522652
chainActive.SetTip(pindexNew);

0 commit comments

Comments
 (0)