Remove the implementation of score-based block template construction

and the `-blockminsize` option.

Signed-off-by: Daira Emma Hopwood <daira@jacaranda.org>
This commit is contained in:
Daira Emma Hopwood 2023-04-19 20:17:44 +01:00
parent 783bd52556
commit c1930170d2
6 changed files with 10 additions and 70 deletions

View File

@ -52,6 +52,9 @@ We now use a new block template construction algorithm documented in
"high priority" because they spent older inputs. The `-blockprioritysize` config
option, which configured the portion of the block reserved for these transactions,
has been removed and will now cause a warning if used.
- The `-blockminsize` option, which configured the size of a portion of the block
to be filled regardless of transaction fees or priority, has also been removed
and will cause a warning if used.
Removal of Priority Estimation
------------------------------

View File

@ -399,9 +399,6 @@ Node relay options:
Block creation options:
-blockminsize=<n>
Set minimum block size in bytes (default: 0)
-blockmaxsize=<n>
Set maximum block size in bytes (default: 2000000)

View File

@ -500,7 +500,6 @@ std::string HelpMessage(HelpMessageMode mode)
strUsage += HelpMessageOpt("-datacarriersize", strprintf(_("Maximum size of data in data carrier transactions we relay and mine (default: %u)"), MAX_OP_RETURN_RELAY));
strUsage += HelpMessageGroup(_("Block creation options:"));
strUsage += HelpMessageOpt("-blockminsize=<n>", strprintf(_("Set minimum block size in bytes (default: %u)"), DEFAULT_BLOCK_MIN_SIZE));
strUsage += HelpMessageOpt("-blockmaxsize=<n>", strprintf(_("Set maximum block size in bytes (default: %d)"), DEFAULT_BLOCK_MAX_SIZE));
if (GetBoolArg("-help-debug", false))
strUsage += HelpMessageOpt("-blockversion=<n>", strprintf("Override block version to test forking scenarios (default: %d)", (int)CBlock::CURRENT_VERSION));
@ -1292,6 +1291,10 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
}
#endif
if (GetArg("-blockminsize", 0) != 0) {
InitWarning(_("The argument -blockminsize is no longer supported."));
}
if (GetArg("-blockprioritysize", 0) != 0) {
InitWarning(_("The argument -blockprioritysize is no longer supported."));
}

View File

@ -339,11 +339,6 @@ BlockAssembler::BlockAssembler(const CChainParams& _chainparams)
nBlockMaxSize = GetArg("-blockmaxsize", DEFAULT_BLOCK_MAX_SIZE);
// Limit to between 1K and MAX_BLOCK_SIZE-1K for sanity:
nBlockMaxSize = std::max((unsigned int)1000, std::min((unsigned int)(MAX_BLOCK_SIZE-1000), nBlockMaxSize));
// Minimum block size you want to create; block will be filled with free transactions
// until there are no more or the block reaches this size:
nBlockMinSize = GetArg("-blockminsize", DEFAULT_BLOCK_MIN_SIZE);
nBlockMinSize = std::min(nBlockMaxSize, nBlockMinSize);
}
void BlockAssembler::resetBlock(const MinerAddress& minerAddress)
@ -730,63 +725,6 @@ void BlockAssembler::addTransactions(
}
}
void BlockAssembler::addScoreTxs()
{
std::priority_queue<CTxMemPool::txiter, std::vector<CTxMemPool::txiter>, ScoreCompare> clearedTxs;
CTxMemPool::setEntries waitSet;
CTxMemPool::indexed_transaction_set::index<mining_score>::type::iterator mi = mempool.mapTx.get<mining_score>().begin();
CTxMemPool::txiter iter;
while (!blockFinished && (mi != mempool.mapTx.get<mining_score>().end() || !clearedTxs.empty()))
{
// If no txs that were previously postponed are available to try
// again, then try the next highest score tx
if (clearedTxs.empty()) {
iter = mempool.mapTx.project<0>(mi);
mi++;
}
// If a previously postponed tx is available to try again, then it
// has higher score than all untried so far txs
else {
iter = clearedTxs.top();
clearedTxs.pop();
}
// If tx already in block, skip (added by addPriorityTxs)
if (inBlock.count(iter)) {
continue;
}
// If tx is dependent on other mempool txs which haven't yet been included
// then put it in the waitSet
if (isStillDependent(iter)) {
waitSet.insert(iter);
continue;
}
// If the fee rate is below the min fee rate for mining, then we're done
// adding txs based on score (fee rate)
if ((iter->GetModifiedFee() < ::minRelayTxFee.GetFee(iter->GetTxSize())) &&
(iter->GetModifiedFee() < DEFAULT_FEE) &&
(nBlockSize >= nBlockMinSize)) {
return;
}
// If this tx fits in the block add it, otherwise keep looping
if (TestForBlock(iter)) {
AddToBlock(iter);
// 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))
{
if (waitSet.count(child)) {
clearedTxs.push(child);
waitSet.erase(child);
}
}
}
}
}
//////////////////////////////////////////////////////////////////////////////
//

View File

@ -107,8 +107,8 @@ private:
// A convenience pointer that always refers to the CBlock in pblocktemplate
CBlock* pblock;
// Configuration parameters for the block size
unsigned int nBlockMaxSize, nBlockMinSize;
// Configuration parameter for the block size
unsigned int nBlockMaxSize;
// Information on the current status of the block
uint64_t nBlockSize;

View File

@ -15,9 +15,8 @@
class CChainParams;
class CCoinsViewCache;
/** Default for -blockmaxsize and -blockminsize, which control the range of sizes the mining code will create **/
/** Default for -blockmaxsize, which controls the maximum block size the mining code will create **/
static const unsigned int DEFAULT_BLOCK_MAX_SIZE = MAX_BLOCK_SIZE;
static const unsigned int DEFAULT_BLOCK_MIN_SIZE = 0;
/** Maximum number of signature check operations in an IsStandard() P2SH script */
static const unsigned int MAX_P2SH_SIGOPS = 15;