diff --git a/src/config.h b/src/config.h --- a/src/config.h +++ b/src/config.h @@ -20,9 +20,6 @@ public: virtual bool SetMaxBlockSize(uint64_t maxBlockSize) = 0; virtual uint64_t GetMaxBlockSize() const = 0; - virtual bool - SetBlockPriorityPercentage(int64_t blockPriorityPercentage) = 0; - virtual uint8_t GetBlockPriorityPercentage() const = 0; virtual const CChainParams &GetChainParams() const = 0; virtual void SetCashAddrEncoding(bool) = 0; virtual bool UseCashAddrEncoding() const = 0; @@ -41,8 +38,6 @@ GlobalConfig(); bool SetMaxBlockSize(uint64_t maxBlockSize) override; uint64_t GetMaxBlockSize() const override; - bool SetBlockPriorityPercentage(int64_t blockPriorityPercentage) override; - uint8_t GetBlockPriorityPercentage() const override; const CChainParams &GetChainParams() const override; void SetCashAddrEncoding(bool) override; bool UseCashAddrEncoding() const override; @@ -69,7 +64,6 @@ /** The largest block size this node will accept. */ uint64_t nMaxBlockSize; - uint64_t nBlockPriorityPercentage; }; // Dummy for subclassing in unittests @@ -80,10 +74,6 @@ DummyConfig(std::unique_ptr chainParamsIn); bool SetMaxBlockSize(uint64_t maxBlockSize) override { return false; } uint64_t GetMaxBlockSize() const override { return 0; } - bool SetBlockPriorityPercentage(int64_t blockPriorityPercentage) override { - return false; - } - uint8_t GetBlockPriorityPercentage() const override { return 0; } void SetChainParams(std::string net); const CChainParams &GetChainParams() const override { return *chainParams; } diff --git a/src/config.cpp b/src/config.cpp --- a/src/config.cpp +++ b/src/config.cpp @@ -7,11 +7,9 @@ #include #include // DEFAULT_MAX_BLOCK_SIZE #include -#include // DEFAULT_BLOCK_PRIORITY_PERCENTAGE GlobalConfig::GlobalConfig() - : useCashAddr(false), nMaxBlockSize(DEFAULT_MAX_BLOCK_SIZE), - nBlockPriorityPercentage(DEFAULT_BLOCK_PRIORITY_PERCENTAGE) {} + : useCashAddr(false), nMaxBlockSize(DEFAULT_MAX_BLOCK_SIZE) {} bool GlobalConfig::SetMaxBlockSize(uint64_t maxBlockSize) { // Do not allow maxBlockSize to be set below historic 1MB limit @@ -28,19 +26,6 @@ return nMaxBlockSize; } -bool GlobalConfig::SetBlockPriorityPercentage(int64_t blockPriorityPercentage) { - // blockPriorityPercentage has to belong to [0..100] - if ((blockPriorityPercentage < 0) || (blockPriorityPercentage > 100)) { - return false; - } - nBlockPriorityPercentage = blockPriorityPercentage; - return true; -} - -uint8_t GlobalConfig::GetBlockPriorityPercentage() const { - return nBlockPriorityPercentage; -} - const CChainParams &GlobalConfig::GetChainParams() const { return Params(); } diff --git a/src/init.cpp b/src/init.cpp --- a/src/init.cpp +++ b/src/init.cpp @@ -894,11 +894,6 @@ strprintf("Set maximum block size in bytes (default: %d)", DEFAULT_MAX_GENERATED_BLOCK_SIZE), false, OptionsCategory::BLOCK_CREATION); - gArgs.AddArg("-blockprioritypercentage=", - strprintf("Set maximum percentage of a block reserved to " - "high-priority/low-fee transactions (default: %d)", - DEFAULT_BLOCK_PRIORITY_PERCENTAGE), - false, OptionsCategory::BLOCK_CREATION); gArgs.AddArg("-blockmintxfee=", strprintf("Set lowest fee rate (in %s/kB) for transactions to " "be included in block creation. (default: %s)", @@ -1483,15 +1478,6 @@ } } - // if space reserved for high priority transactions is misconfigured - // stop program execution and warn the user with a proper error message - const int64_t blkprio = gArgs.GetArg("-blockprioritypercentage", - DEFAULT_BLOCK_PRIORITY_PERCENTAGE); - if (!config.SetBlockPriorityPercentage(blkprio)) { - return InitError(_("Block priority percentage has to belong to the " - "[0..100] interval.")); - } - // -bind and -whitebind can't be set when not listening size_t nUserBind = gArgs.GetArgs("-bind").size() + gArgs.GetArgs("-whitebind").size(); diff --git a/src/miner.h b/src/miner.h --- a/src/miner.h +++ b/src/miner.h @@ -156,7 +156,6 @@ int64_t nLockTimeCutoff; int64_t nMedianTimePast; const CChainParams &chainparams; - uint8_t nBlockPriorityPercentage; const CTxMemPool *mempool; @@ -169,7 +168,6 @@ uint64_t nExcessiveBlockSize; uint64_t nMaxGeneratedBlockSize; CFeeRate blockMinFeeRate; - uint8_t nBlockPriorityPercentage; }; BlockAssembler(const Config &config, const CTxMemPool &_mempool); @@ -190,8 +188,6 @@ void AddToBlock(CTxMemPool::txiter iter); // Methods for how to add transactions to a block. - /** Add transactions based on tx "priority" */ - void addPriorityTxs() EXCLUSIVE_LOCKS_REQUIRED(mempool->cs); /** * Add transactions based on feerate including unconfirmed ancestors. * Increments nPackagesSelected / nDescendantsUpdated with corresponding diff --git a/src/miner.cpp b/src/miner.cpp --- a/src/miner.cpp +++ b/src/miner.cpp @@ -61,8 +61,7 @@ BlockAssembler::Options::Options() : nExcessiveBlockSize(DEFAULT_MAX_BLOCK_SIZE), nMaxGeneratedBlockSize(DEFAULT_MAX_GENERATED_BLOCK_SIZE), - blockMinFeeRate(DEFAULT_BLOCK_MIN_TX_FEE_PER_KB), - nBlockPriorityPercentage(DEFAULT_BLOCK_PRIORITY_PERCENTAGE) {} + blockMinFeeRate(DEFAULT_BLOCK_MIN_TX_FEE_PER_KB) {} BlockAssembler::BlockAssembler(const CChainParams ¶ms, const CTxMemPool &_mempool, @@ -73,8 +72,6 @@ nMaxGeneratedBlockSize = std::max( 1000, std::min(options.nExcessiveBlockSize - 1000, options.nMaxGeneratedBlockSize)); - // Reserve a portion of the block for high priority transactions. - nBlockPriorityPercentage = options.nBlockPriorityPercentage; } static BlockAssembler::Options DefaultOptions(const Config &config) { @@ -97,8 +94,6 @@ options.blockMinFeeRate = CFeeRate(n); } - options.nBlockPriorityPercentage = config.GetBlockPriorityPercentage(); - return options; } @@ -157,7 +152,6 @@ ? nMedianTimePast : pblock->GetBlockTime(); - addPriorityTxs(); int nPackagesSelected = 0; int nDescendantsUpdated = 0; addPackageTxs(nPackagesSelected, nDescendantsUpdated); @@ -582,93 +576,6 @@ } } -void BlockAssembler::addPriorityTxs() { - // How much of the block should be dedicated to high-priority transactions. - if (nBlockPriorityPercentage == 0) { - return; - } - - uint64_t nBlockPrioritySize = - nMaxGeneratedBlockSize * nBlockPriorityPercentage / 100; - - // This vector will be sorted into a priority queue: - std::vector vecPriority; - TxCoinAgePriorityCompare pricomparer; - std::map - waitPriMap; - typedef std::map::iterator waitPriIter; - double actualPriority = -1; - - vecPriority.reserve(mempool->mapTx.size()); - for (CTxMemPool::indexed_transaction_set::iterator mi = - mempool->mapTx.begin(); - mi != mempool->mapTx.end(); ++mi) { - double dPriority = mi->GetPriority(nHeight); - Amount dummy; - mempool->ApplyDeltas(mi->GetTx().GetId(), dPriority, dummy); - vecPriority.push_back(TxCoinAgePriority(dPriority, mi)); - } - std::make_heap(vecPriority.begin(), vecPriority.end(), pricomparer); - - CTxMemPool::txiter iter; - - // Add a tx from priority queue to fill the part of block reserved to - // priority transactions. - while (!vecPriority.empty()) { - iter = vecPriority.front().second; - actualPriority = vecPriority.front().first; - std::pop_heap(vecPriority.begin(), vecPriority.end(), pricomparer); - vecPriority.pop_back(); - - // If tx already in block, skip. - if (inBlock.count(iter)) { - // Shouldn't happen for priority txs. - assert(false); - continue; - } - - // If tx is dependent on other mempool txs which haven't yet been - // included then put it in the waitSet. - if (isStillDependent(iter)) { - waitPriMap.insert(std::make_pair(iter, actualPriority)); - continue; - } - - TestForBlockResult testResult = TestForBlock(iter); - // Break if the block is completed - if (testResult == TestForBlockResult::BlockFinished) { - break; - } - - // If this tx does not fit in the block, skip to next transaction. - if (testResult != TestForBlockResult::TXFits) { - continue; - } - - AddToBlock(iter); - - // If now that this txs is added we've surpassed our desired priority - // size, then we're done adding priority transactions. - if (nBlockSize >= nBlockPrioritySize) { - break; - } - - // This tx was successfully added, so add transactions that depend - // on this one to the priority queue to try again. - for (CTxMemPool::txiter child : mempool->GetMemPoolChildren(iter)) { - waitPriIter wpiter = waitPriMap.find(child); - if (wpiter == waitPriMap.end()) { - continue; - } - - vecPriority.push_back(TxCoinAgePriority(wpiter->second, child)); - std::push_heap(vecPriority.begin(), vecPriority.end(), pricomparer); - waitPriMap.erase(wpiter); - } - } -} - static const std::vector getExcessiveBlockSizeSig(uint64_t nExcessiveBlockSize) { std::string cbmsg = "/EB" + getSubVersionEB(nExcessiveBlockSize) + "/"; diff --git a/src/policy/policy.h b/src/policy/policy.h --- a/src/policy/policy.h +++ b/src/policy/policy.h @@ -22,11 +22,6 @@ * mining code will create. */ static const uint64_t DEFAULT_MAX_GENERATED_BLOCK_SIZE = 2 * ONE_MEGABYTE; -/** - * Default for -blockprioritypercentage, define the amount of block space - * reserved to high priority transactions. - */ -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. diff --git a/src/rpc/mining.cpp b/src/rpc/mining.cpp --- a/src/rpc/mining.cpp +++ b/src/rpc/mining.cpp @@ -254,9 +254,6 @@ obj.pushKV("currentblocksize", uint64_t(nLastBlockSize)); obj.pushKV("currentblocktx", uint64_t(nLastBlockTx)); obj.pushKV("difficulty", double(GetDifficulty(chainActive.Tip()))); - obj.pushKV("blockprioritypercentage", - uint8_t(gArgs.GetArg("-blockprioritypercentage", - DEFAULT_BLOCK_PRIORITY_PERCENTAGE))); obj.pushKV("networkhashps", getnetworkhashps(config, request)); obj.pushKV("pooledtx", uint64_t(g_mempool.size())); obj.pushKV("chain", config.GetChainParams().NetworkIDString()); 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 @@ -48,7 +48,6 @@ const CTxMemPool &mempool) { BlockAssembler::Options options; options.blockMinFeeRate = blockMinFeeRate; - options.nBlockPriorityPercentage = 0; return BlockAssembler(params, mempool, options); } @@ -102,7 +101,6 @@ // 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 blockprioritypercentage is 0. static void TestPackageSelection(const CChainParams &chainparams, const CScript &scriptPubKey, const std::vector &txFirst) diff --git a/test/functional/feature_bip68_sequence.py b/test/functional/feature_bip68_sequence.py --- a/test/functional/feature_bip68_sequence.py +++ b/test/functional/feature_bip68_sequence.py @@ -46,8 +46,8 @@ class BIP68Test(BitcoinTestFramework): def set_test_params(self): self.num_nodes = 2 - self.extra_args = [["-blockprioritypercentage=0", "-noparkdeepreorg", "-maxreorgdepth=-1"], - ["-blockprioritypercentage=0", "-acceptnonstdtxn=0", "-maxreorgdepth=-1"]] + self.extra_args = [["-noparkdeepreorg", "-maxreorgdepth=-1"], + ["-acceptnonstdtxn=0", "-maxreorgdepth=-1"]] def run_test(self): self.relayfee = self.nodes[0].getnetworkinfo()["relayfee"]