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:
    ACK 04528054fc
  stickies-v:
    ACK 04528054f

Tree-SHA512: 38c138d6a75616651f9b1faf4e3a1cd833437a486f4e84308fbee958e8462bb570582c88f7ba7ab99d80191e97855ac2cf27c43cc21585d3e4b0e227effe2fb5
This commit is contained in:
Andrew Chow
2023-01-11 18:02:59 -05:00
6 changed files with 54 additions and 13 deletions

View File

@@ -16,6 +16,7 @@
#include <boost/multi_index/ordered_index.hpp>
#include <boost/multi_index_container.hpp>
class ArgsManager;
class ChainstateManager;
class CBlockIndex;
class CChainParams;
@@ -135,6 +136,9 @@ private:
unsigned int nBlockMaxWeight;
CFeeRate blockMinFeeRate;
// Whether to call TestBlockValidity() at the end of CreateNewBlock().
const bool test_block_validity;
// Information on the current status of the block
uint64_t nBlockWeight;
uint64_t nBlockTx;
@@ -155,6 +159,7 @@ public:
Options();
size_t nBlockMaxWeight;
CFeeRate blockMinFeeRate;
bool test_block_validity;
};
explicit BlockAssembler(Chainstate& chainstate, const CTxMemPool* mempool);
@@ -197,6 +202,9 @@ int64_t UpdateTime(CBlockHeader* pblock, const Consensus::Params& consensusParam
/** Update an old GenerateCoinbaseCommitment from CreateNewBlock after the block txs have changed */
void RegenerateCommitments(CBlock& block, ChainstateManager& chainman);
/** Apply -blockmintxfee and -blockmaxweight options from ArgsManager to BlockAssembler options. */
void ApplyArgsManOptions(const ArgsManager& gArgs, BlockAssembler::Options& options);
} // namespace node
#endif // BITCOIN_NODE_MINER_H