mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-12 06:58:57 +01:00
Merge bitcoin/bitcoin#26695: bench: BlockAssembler on a mempool with packages
04528054fc[bench] BlockAssembler with mempool packages (glozow)6ce265acf4[test util] lock cs_main before pool.cs in PopulateMempool (glozow)8791410662[test util] randomize fee in PopulateMempool (glozow)cba5934eb6[miner] allow bypassing TestBlockValidity (glozow)c058852308[refactor] parameterize BlockAssembler::Options in PrepareBlock (glozow)a2de971ba1[refactor] add helper to apply ArgsManager to BlockAssembler::Options (glozow) Pull request description: Performance of block template building matters as miners likely want to be able to start mining on a block with transactions asap after a block is found. We would want to know if a mempool PR accidentally caused, for example, a 100x slowdown. An `AssembleBlock()` bench exists, but it operates on a mempool with 101 transactions, each with 0 ancestors or descendants and with the same fee. Adding a bench with a more complex mempool is useful because (1) it's more realistic (2) updating packages can potentially cause the algorithm to take a long time. ACKs for top commit: kevkevinpal: Tested ACK [0452805](04528054fc) achow101: ACK04528054fcstickies-v: ACK04528054fTree-SHA512: 38c138d6a75616651f9b1faf4e3a1cd833437a486f4e84308fbee958e8462bb570582c88f7ba7ab99d80191e97855ac2cf27c43cc21585d3e4b0e227effe2fb5
This commit is contained in:
@@ -397,15 +397,15 @@ std::vector<CTransactionRef> TestChain100Setup::PopulateMempool(FastRandomContex
|
||||
unspent_prevouts.pop_front();
|
||||
}
|
||||
const size_t num_outputs = det_rand.randrange(24) + 1;
|
||||
// Approximately 1000sat "fee," equal output amounts.
|
||||
const CAmount amount_per_output = (total_in - 1000) / num_outputs;
|
||||
const CAmount fee = 100 * det_rand.randrange(30);
|
||||
const CAmount amount_per_output = (total_in - fee) / num_outputs;
|
||||
for (size_t n{0}; n < num_outputs; ++n) {
|
||||
CScript spk = CScript() << CScriptNum(num_transactions + n);
|
||||
mtx.vout.push_back(CTxOut(amount_per_output, spk));
|
||||
}
|
||||
CTransactionRef ptx = MakeTransactionRef(mtx);
|
||||
mempool_transactions.push_back(ptx);
|
||||
if (amount_per_output > 2000) {
|
||||
if (amount_per_output > 3000) {
|
||||
// If the value is high enough to fund another transaction + fees, keep track of it so
|
||||
// it can be used to build a more complex transaction graph. Insert randomly into
|
||||
// unspent_prevouts for extra randomness in the resulting structures.
|
||||
@@ -415,9 +415,11 @@ std::vector<CTransactionRef> TestChain100Setup::PopulateMempool(FastRandomContex
|
||||
}
|
||||
}
|
||||
if (submit) {
|
||||
LOCK2(m_node.mempool->cs, cs_main);
|
||||
LOCK2(cs_main, m_node.mempool->cs);
|
||||
LockPoints lp;
|
||||
m_node.mempool->addUnchecked(CTxMemPoolEntry(ptx, 1000, 0, 1, false, 4, lp));
|
||||
m_node.mempool->addUnchecked(CTxMemPoolEntry(ptx, /*fee=*/(total_in - num_outputs * amount_per_output),
|
||||
/*time=*/0, /*entry_height=*/1,
|
||||
/*spends_coinbase=*/false, /*sigops_cost=*/4, lp));
|
||||
}
|
||||
--num_transactions;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user