Skip to content

Commit 5f2df0e

Browse files
committed
[miner] lower default -blockmintxfee to 1sat/kvB
Back when we implemented coin age priority as a miner policy, miners mempools might admit transactions paying very low fees, but then want to set a higher fee for block inclusion. However, since coin age priority was removed in v0.15, the block assembly policy is solely based on fees, so we do not need to apply minimum feerate rules in multiple places. In fact, the block assembly policy ignoring transactions that are added to the mempool is likely undesirable as we waste resources accepting and storing this transaction. Instead, rely on mempool policy to enforce a minimum entry feerate to the mempool (minrelaytxfee). Set the minimum block feerate to the minimum non-zero amount (1sat/kvB) so it collects everything it finds in mempool into the block.
1 parent d6213d6 commit 5f2df0e

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

src/policy/policy.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ static constexpr unsigned int DEFAULT_BLOCK_RESERVED_WEIGHT{8000};
2929
* Setting a lower value is prevented at startup. */
3030
static constexpr unsigned int MINIMUM_BLOCK_RESERVED_WEIGHT{2000};
3131
/** Default for -blockmintxfee, which sets the minimum feerate for a transaction in blocks created by mining code **/
32-
static constexpr unsigned int DEFAULT_BLOCK_MIN_TX_FEE{1000};
32+
static constexpr unsigned int DEFAULT_BLOCK_MIN_TX_FEE{1};
3333
/** The maximum weight for transactions we're willing to relay/mine */
3434
static constexpr int32_t MAX_STANDARD_TX_WEIGHT{400000};
3535
/** The minimum non-witness size for transactions we're willing to relay/mine: one larger than 64 */

src/test/miner_tests.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include <node/miner.h>
1313
#include <policy/policy.h>
1414
#include <test/util/random.h>
15+
#include <test/util/transaction_utils.h>
1516
#include <test/util/txmempool.h>
1617
#include <txmempool.h>
1718
#include <uint256.h>
@@ -216,6 +217,9 @@ void MinerTestingSetup::TestPackageSelection(const CScript& scriptPubKey, const
216217
tx.vout.resize(2);
217218
tx.vout[0].nValue = 5000000000LL - 100000000;
218219
tx.vout[1].nValue = 100000000; // 1BTC output
220+
// Increase size to avoid rounding errors: when the feerate is extremely small (i.e. 1sat/kvB), evaluating the fee
221+
// at a smaller transaction size gives us a rounded value of 0.
222+
BulkTransaction(tx, 4000);
219223
Txid hashFreeTx2 = tx.GetHash();
220224
AddToMempool(tx_mempool, entry.Fee(0).SpendsCoinbase(true).FromTx(tx));
221225

test/functional/mining_basic.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
MAX_TIMEWARP = 600
5656
VERSIONBITS_TOP_BITS = 0x20000000
5757
VERSIONBITS_DEPLOYMENT_TESTDUMMY_BIT = 28
58-
DEFAULT_BLOCK_MIN_TX_FEE = 1000 # default `-blockmintxfee` setting [sat/kvB]
58+
DEFAULT_BLOCK_MIN_TX_FEE = 1 # default `-blockmintxfee` setting [sat/kvB]
5959

6060
class MiningTest(BitcoinTestFramework):
6161
def set_test_params(self):
@@ -144,7 +144,7 @@ def test_blockmintxfee_parameter(self):
144144
node = self.nodes[0]
145145

146146
# test default (no parameter), zero and a bunch of arbitrary blockmintxfee rates [sat/kvB]
147-
for blockmintxfee_sat_kvb in (DEFAULT_BLOCK_MIN_TX_FEE, 0, 1, 5, 10, 50, 100, 500, 2500, 5000, 21000, 333333, 2500000):
147+
for blockmintxfee_sat_kvb in (DEFAULT_BLOCK_MIN_TX_FEE, 0, 5, 10, 50, 100, 500, 1000, 2500, 5000, 21000, 333333, 2500000):
148148
blockmintxfee_btc_kvb = blockmintxfee_sat_kvb / Decimal(COIN)
149149
if blockmintxfee_sat_kvb == DEFAULT_BLOCK_MIN_TX_FEE:
150150
self.log.info(f"-> Default -blockmintxfee setting ({blockmintxfee_sat_kvb} sat/kvB)...")

0 commit comments

Comments
 (0)