Sunday, December 22, 2024

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

That is meant 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 development.

At a excessive stage, the mempool types transactions by ancestor feerate, and within the mining algorithm we iterate over these transactions in descending ancestor feerate order to pick transactions for a block. As we choose transactions, now we have 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 have been to kind a baby transaction primarily based on an ancestor feerate that’s greater than its personal feerate, you may count on that it has some greater feerate mum or dad that will be chosen first, and subsequently the kid’s ancestor feerate would overstate its true mining rating. This in flip would imply that we’d have a look at many extra transactions from the mempool than needs to be crucial when developing a block, as a result of these youngsters would seem earlier within the mempool’s kind, so we might have 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.

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest Articles