Merge bitcoin/bitcoin#23693: Revert "Fixes Bug in Transaction generation in ComplexMempool benchmark"

faa185bb3abe5fdaeeae14706bad9437acac6a69 Revert "Fixes Bug in Transaction generation in ComplexMempool benchmark" (MarcoFalke)

Pull request description:

  Developers are reporting crashes (potentially OOM) on IRC, but I can't reproduce. Still, revert this for now, since one developer reported the bare metal this was running on crashed.

Top commit has no ACKs.

Tree-SHA512: 080db4fcfc682b68f4cc40dfabd9d3e0e3f6e6297ce4b782d5de2c83bc18f85f60efb1cda64c51e23c4fd2a05222a904e7a11853d9f9c052dcd26a53aa00b235
This commit is contained in:
MarcoFalke 2021-12-07 14:52:14 +01:00 committed by pasta
parent 0d1c8f914c
commit 7125bfaa9c

View File

@ -60,7 +60,7 @@ static void ComplexMemPool(benchmark::Bench& bench)
size_t n_ancestors = det_rand.randrange(10)+1; size_t n_ancestors = det_rand.randrange(10)+1;
for (size_t ancestor = 0; ancestor < n_ancestors && !available_coins.empty(); ++ancestor){ for (size_t ancestor = 0; ancestor < n_ancestors && !available_coins.empty(); ++ancestor){
size_t idx = det_rand.randrange(available_coins.size()); size_t idx = det_rand.randrange(available_coins.size());
Available& coin = available_coins[idx]; Available coin = available_coins[idx];
uint256 hash = coin.ref->GetHash(); uint256 hash = coin.ref->GetHash();
// biased towards taking just one ancestor, but maybe more // biased towards taking just one ancestor, but maybe more
size_t n_to_take = det_rand.randrange(2) == 0 ? 1 : 1+det_rand.randrange(coin.ref->vout.size() - coin.vin_left); size_t n_to_take = det_rand.randrange(2) == 0 ? 1 : 1+det_rand.randrange(coin.ref->vout.size() - coin.vin_left);
@ -69,17 +69,15 @@ static void ComplexMemPool(benchmark::Bench& bench)
tx.vin.back().prevout = COutPoint(hash, coin.vin_left++); tx.vin.back().prevout = COutPoint(hash, coin.vin_left++);
tx.vin.back().scriptSig = CScript() << coin.tx_count; tx.vin.back().scriptSig = CScript() << coin.tx_count;
} }
if (coin.vin_left == coin.ref->vout.size()) { if (coin.vin_left == coin.ref->vin.size()) {
if(available_coins.size()-1!=idx){ // if idx is not the last index swap it with the end index coin = available_coins.back();
std::swap(available_coins[idx], available_coins.back());
}
available_coins.pop_back(); available_coins.pop_back();
} }
} tx.vout.resize(det_rand.randrange(10)+2);
tx.vout.resize(det_rand.randrange(10)+2); for (auto& out : tx.vout) {
for (auto& out : tx.vout) { out.scriptPubKey = CScript() << CScriptNum(tx_counter) << OP_EQUAL;
out.scriptPubKey = CScript() << CScriptNum(tx_counter) << OP_EQUAL; out.nValue = 10 * COIN;
out.nValue = 10 * COIN; }
} }
ordered_coins.emplace_back(MakeTransactionRef(tx)); ordered_coins.emplace_back(MakeTransactionRef(tx));
available_coins.emplace_back(ordered_coins.back(), tx_counter++); available_coins.emplace_back(ordered_coins.back(), tx_counter++);