1

CTxMemPool has a member named rollingMinimumFeeRate:

    mutable double rollingMinimumFeeRate GUARDED_BY(cs); //!< minimum fee to get into the pool, decreases exponentially

The comment explains that it is the minimum fee to get into the pool. But we have another variable in the code base called minRelayTxFee:

CFeeRate minRelayTxFee = CFeeRate(DEFAULT_MIN_RELAY_TX_FEE);
/** Default for -minrelaytxfee, minimum relay fee for transactions */
static const unsigned int DEFAULT_MIN_RELAY_TX_FEE = 1000;

Two questions:

  1. What is the difference between these two variables? and which is for what use cases?

  2. Why the rollingMinimumFeeRate decreases exponentially?

1 Answer 1

3

What is the difference between these two variables? and which is for what use cases?

rollingMinimumFeeRate is the minimum feerate for a transaction to be added to the mempool and be further relayed. This is a dynamic value - it changes as the mempool fills up and empties.

minRelayTxFee is the absolute minimum feerate. It is a static value. rollingMinimumFeeRate starts with the value of minRelayTxFee and it increases when the mempool becomes full. As the mempool empties and rollingMinimumFeeRate decreases, it will not decrease to be less than minRelayTxFee. (This is effectively what happens, not actually what the code does.)

Why the rollingMinimumFeeRate decreases exponentially?

rollingMinimumFeeRate increases when the mempool fills up. Transactions that have a feerate less than this value are evicted from the mempool. It is increased in order to maintain a maximum mempool size - if the mempool is larger than the maximum, the lowest feerate transactions are evicted until the maximum size is reached, and rollingMinimumFeeRate is set to the highest feerate transaction that was evicted.

As transactions are removed from the mempool by blocks, there needs to be a way to decrease rollingMinimumFeeRate to allow lower feerate transactions back in. However because it does not have those transactions anymore, it does not know what value to set it to. So it walks backwards, exponentially, until it either reaches 0, or is increased again, then the exponential decreasing is reset.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.