mining concept – Why does Bitcoin Core’s algorithm makes use of ancestor rating as an alternative of simply ancestor payment charge to pick out transactions?

0
25


That is supposed to be a efficiency optimization when producing a block template for mining. The problem is round what number of transactions we find yourself whereas iterating over the mempool throughout block building.

At a excessive degree, the mempool types transactions by ancestor feerate, and within the mining algorithm we iterate over these transactions in descending ancestor feerate order to pick out transactions for a block. As we choose transactions, we have now to do some bookkeeping to replace the brand new ancestor scores of descendants of these transactions (to mirror solely the ancestors that aren’t but chosen), however as a result of we will not modify the mempool when developing blocks, we nonetheless look at every transaction in the identical order it seems within the mempool.

So if the mempool had been to type a toddler transaction primarily based on an ancestor feerate that’s larger than its personal feerate, you may count on that it has some larger feerate guardian that may be chosen first, and subsequently the kid’s ancestor feerate would overstate its true mining rating. This in flip would imply that we’d take a look at many extra transactions from the mempool than ought to be essential when developing a block, as a result of these youngsters would seem earlier within the mempool’s type, so we would take a look at them solely to resolve that the true feerate is decrease than indicated. As a substitute, we attempt to
keep away from this situation by sorting transactions primarily based on the minimal of the 2 feerates.

The implementation particulars are considerably extra concerned than I described; see https://github.com/bitcoin/bitcoin/blob/d80348ccb65601d19b4b408d442e0999b5a6cf98/src/node/miner.cpp#L292C1-L429 for the total mining logic.

LEAVE A REPLY

Please enter your comment!
Please enter your name here