diff --git a/qa/rpc-tests/bip68-sequence.py b/qa/rpc-tests/bip68-sequence.py --- a/qa/rpc-tests/bip68-sequence.py +++ b/qa/rpc-tests/bip68-sequence.py @@ -32,9 +32,9 @@ def setup_network(self): self.nodes = [] self.nodes.append( - start_node(0, self.options.tmpdir, ["-blockprioritysize=0"])) + start_node(0, self.options.tmpdir, ["-blockprioritypercentage=0"])) self.nodes.append( - start_node(1, self.options.tmpdir, ["-blockprioritysize=0", + start_node(1, self.options.tmpdir, ["-blockprioritypercentage=0", "-acceptnonstdtxn=0"])) self.is_network_split = False self.relayfee = self.nodes[0].getnetworkinfo()["relayfee"] diff --git a/qa/rpc-tests/smartfees.py b/qa/rpc-tests/smartfees.py --- a/qa/rpc-tests/smartfees.py +++ b/qa/rpc-tests/smartfees.py @@ -214,14 +214,14 @@ # NOTE: the CreateNewBlock code starts counting block size at 1,000 bytes, # (17k is room enough for 110 or so transactions) self.nodes.append(start_node(1, self.options.tmpdir, - ["-blockprioritysize=1500", "-blockmaxsize=17000", + ["-blockprioritypercentage=9", "-blockmaxsize=17000", "-maxorphantx=1000"], stderr_checker=OutputChecker())) connect_nodes(self.nodes[1], 0) # Node2 is a stingy miner, that # produces too small blocks (room for only 55 or so transactions) - node2args = ["-blockprioritysize=0", + node2args = ["-blockprioritypercentage=0", "-blockmaxsize=8000", "-maxorphantx=1000"] self.nodes.append( @@ -294,5 +294,6 @@ self.log.info("Final estimates after emptying mempools") check_estimates(self.nodes[1], self.fees_per_kb, 2) + if __name__ == '__main__': EstimateFeeTest().main() diff --git a/src/init.cpp b/src/init.cpp --- a/src/init.cpp +++ b/src/init.cpp @@ -784,11 +784,11 @@ "-blockmaxsize=", strprintf(_("Set maximum block size in bytes (default: %d)"), DEFAULT_MAX_GENERATED_BLOCK_SIZE)); - strUsage += - HelpMessageOpt("-blockprioritysize=", - strprintf(_("Set maximum size of high-priority/low-fee " - "transactions in bytes (default: %d)"), - DEFAULT_BLOCK_PRIORITY_SIZE)); + strUsage += HelpMessageOpt( + "-blockprioritypercentage=", + strprintf(_("Set maximum percentage in size of high-priority/low-fee " + "transactions in bytes (default: %d)"), + DEFAULT_BLOCK_PRIORITY_PERCENTAGE)); strUsage += HelpMessageOpt( "-blockmintxfee=", strprintf(_("Set lowest fee rate (in %s/kB) for transactions to be " diff --git a/src/miner.cpp b/src/miner.cpp --- a/src/miner.cpp +++ b/src/miner.cpp @@ -561,13 +561,20 @@ void BlockAssembler::addPriorityTxs() { // How much of the block should be dedicated to high-priority transactions, // included regardless of the fees they pay. - uint64_t nBlockPrioritySize = - GetArg("-blockprioritysize", DEFAULT_BLOCK_PRIORITY_SIZE); - nBlockPrioritySize = std::min(nMaxGeneratedBlockSize, nBlockPrioritySize); - if (nBlockPrioritySize == 0) { + uint8_t nBlockPriorityPercentage = + GetArg("-blockprioritypercentage", DEFAULT_BLOCK_PRIORITY_PERCENTAGE); + if (nBlockPriorityPercentage == 0) { return; } + // nBlockPriorityPercentage needs to belong to [0..100] interval + nBlockPriorityPercentage = + std::min(static_cast(100), nBlockPriorityPercentage); + nBlockPriorityPercentage = + std::max(static_cast(0), nBlockPriorityPercentage); + uint64_t nBlockPrioritySize = + nMaxGeneratedBlockSize * nBlockPriorityPercentage / 100; + // This vector will be sorted into a priority queue: std::vector vecPriority; TxCoinAgePriorityCompare pricomparer; @@ -590,7 +597,8 @@ CTxMemPool::txiter iter; - // Add a tx from priority queue to fill the blockprioritysize. + // Add a tx from priority queue to fill the part of block reserved to + // priority transactions. while (!vecPriority.empty() && !blockFinished) { iter = vecPriority.front().second; actualPriority = vecPriority.front().first; diff --git a/src/policy/policy.h b/src/policy/policy.h --- a/src/policy/policy.h +++ b/src/policy/policy.h @@ -17,9 +17,10 @@ /** Default for -blockmaxsize, which controls the maximum size of block the * mining code will create **/ static const uint64_t DEFAULT_MAX_GENERATED_BLOCK_SIZE = 2 * ONE_MEGABYTE; -/** Default for -blockprioritysize, maximum space for zero/low-fee transactions +/** Default for -blockprioritypercentage, maximum percentage space for + * zero/low-fee transactions * **/ -static const uint64_t DEFAULT_BLOCK_PRIORITY_SIZE = 0; +static const uint64_t DEFAULT_BLOCK_PRIORITY_PERCENTAGE = 5; /** Default for -blockmintxfee, which sets the minimum feerate for a transaction * in blocks created by mining code **/ static const unsigned int DEFAULT_BLOCK_MIN_TX_FEE = 1000; diff --git a/src/test/miner_tests.cpp b/src/test/miner_tests.cpp --- a/src/test/miner_tests.cpp +++ b/src/test/miner_tests.cpp @@ -78,7 +78,7 @@ // Test suite for ancestor feerate transaction selection. // Implemented as an additional function, rather than a separate test case, to // allow reusing the blockchain created in CreateNewBlock_validity. -// Note that this test assumes blockprioritysize is 0. +// Note that this test assumes blockprioritypercentage is 0. void TestPackageSelection(const CChainParams &chainparams, CScript scriptPubKey, std::vector &txFirst) { // Test the ancestor feerate transaction selection. @@ -86,6 +86,9 @@ GlobalConfig config; + // these 3 tests assume blockprioritypercentage is 0. + ForceSetArg("-blockprioritypercentage", "0"); + // Test that a medium fee transaction will be selected after a higher fee // rate package with a low fee rate parent. CMutableTransaction tx;