Skip to content

Commit 1dc03dd

Browse files
committed
[doc] remove non-signaling mentions of BIP125
Our RBF policy is different from the rules specified in BIP125. For example, the BIP does not mention Rule 6, and our Rule 4 uses the (configurable) incremental relay feerate (distinct from the minimum relay feerate). Those interested in our policy should refer to doc/policy/mempool-replacements.md instead. These rules may also continue to diverge with package RBF and other RBF improvements. Keep references to the BIP125 signaling wrt sequence numbers, since that is still correct and widely used. It is helpful to refer to this as "BIP125 signaling" since it is unambiguous and succint, especially if we have multiple ways to signal replaceability in the future. The rule numbers in doc/policy/mempool-replacements.md correspond largely to those of BIP 125, so we can still refer to them like "Rule 5."
1 parent 32024d4 commit 1dc03dd

File tree

15 files changed

+40
-40
lines changed

15 files changed

+40
-40
lines changed

doc/policy/packages.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ The following rules are enforced for all packages:
3333
* Packages cannot have conflicting transactions, i.e. no two transactions in a package can spend
3434
the same inputs. Packages cannot have duplicate transactions. (#20833)
3535

36-
* No transaction in a package can conflict with a mempool transaction. BIP125 Replace By Fee is
36+
* No transaction in a package can conflict with a mempool transaction. Replace By Fee is
3737
currently disabled for packages. (#20833)
3838

3939
- Package RBF may be enabled in the future.

src/init.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -556,7 +556,7 @@ void SetupServerArgs(ArgsManager& argsman)
556556
SetupChainParamsBaseOptions(argsman);
557557

558558
argsman.AddArg("-acceptnonstdtxn", strprintf("Relay and mine \"non-standard\" transactions (%sdefault: %u)", "testnet/regtest only; ", !testnetChainParams->RequireStandard()), ArgsManager::ALLOW_ANY | ArgsManager::DEBUG_ONLY, OptionsCategory::NODE_RELAY);
559-
argsman.AddArg("-incrementalrelayfee=<amt>", strprintf("Fee rate (in %s/kvB) used to define cost of relay, used for mempool limiting and BIP 125 replacement. (default: %s)", CURRENCY_UNIT, FormatMoney(DEFAULT_INCREMENTAL_RELAY_FEE)), ArgsManager::ALLOW_ANY | ArgsManager::DEBUG_ONLY, OptionsCategory::NODE_RELAY);
559+
argsman.AddArg("-incrementalrelayfee=<amt>", strprintf("Fee rate (in %s/kvB) used to define cost of relay, used for mempool limiting and replacement policy. (default: %s)", CURRENCY_UNIT, FormatMoney(DEFAULT_INCREMENTAL_RELAY_FEE)), ArgsManager::ALLOW_ANY | ArgsManager::DEBUG_ONLY, OptionsCategory::NODE_RELAY);
560560
argsman.AddArg("-dustrelayfee=<amt>", strprintf("Fee rate (in %s/kvB) used to define dust, the value of an output such that it will cost more than its value in fees at this fee rate to spend it. (default: %s)", CURRENCY_UNIT, FormatMoney(DUST_RELAY_TX_FEE)), ArgsManager::ALLOW_ANY | ArgsManager::DEBUG_ONLY, OptionsCategory::NODE_RELAY);
561561
argsman.AddArg("-bytespersigop", strprintf("Equivalent bytes per sigop in transactions for relay and mining (default: %u)", DEFAULT_BYTES_PER_SIGOP), ArgsManager::ALLOW_ANY, OptionsCategory::NODE_RELAY);
562562
argsman.AddArg("-datacarrier", strprintf("Relay and mine data carrier transactions (default: %u)", DEFAULT_ACCEPT_DATACARRIER), ArgsManager::ALLOW_ANY, OptionsCategory::NODE_RELAY);

src/node/mempool_args.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ std::optional<bilingual_str> ApplyArgsManOptions(const ArgsManager& argsman, con
4545

4646
if (auto hours = argsman.GetIntArg("-mempoolexpiry")) mempool_opts.expiry = std::chrono::hours{*hours};
4747

48-
// incremental relay fee sets the minimum feerate increase necessary for BIP 125 replacement in the mempool
48+
// incremental relay fee sets the minimum feerate increase necessary for replacement in the mempool
4949
// and the amount the mempool min fee increases above the feerate of txs evicted due to mempool limiting.
5050
if (argsman.IsArgSet("-incrementalrelayfee")) {
5151
if (std::optional<CAmount> inc_relay_fee = ParseMoney(argsman.GetArg("-incrementalrelayfee", ""))) {

src/policy/policy.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ static constexpr unsigned int MIN_STANDARD_TX_NONWITNESS_SIZE{82};
3131
static constexpr unsigned int MAX_P2SH_SIGOPS{15};
3232
/** The maximum number of sigops we're willing to relay/mine in a single tx */
3333
static constexpr unsigned int MAX_STANDARD_TX_SIGOPS_COST{MAX_BLOCK_SIGOPS_COST/5};
34-
/** Default for -incrementalrelayfee, which sets the minimum feerate increase for mempool limiting or BIP 125 replacement **/
34+
/** Default for -incrementalrelayfee, which sets the minimum feerate increase for mempool limiting or replacement **/
3535
static constexpr unsigned int DEFAULT_INCREMENTAL_RELAY_FEE{1000};
3636
/** Default for -bytespersigop */
3737
static constexpr unsigned int DEFAULT_BYTES_PER_SIGOP{20};

src/policy/rbf.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ std::optional<std::string> GetEntriesForConflicts(const CTransaction& tx,
6565
uint64_t nConflictingCount = 0;
6666
for (const auto& mi : iters_conflicting) {
6767
nConflictingCount += mi->GetCountWithDescendants();
68-
// BIP125 Rule #5: don't consider replacing more than MAX_REPLACEMENT_CANDIDATES
68+
// Rule #5: don't consider replacing more than MAX_REPLACEMENT_CANDIDATES
6969
// entries from the mempool. This potentially overestimates the number of actual
7070
// descendants (i.e. if multiple conflicts share a descendant, it will be counted multiple
7171
// times), but we just want to be conservative to avoid doing too much work.
@@ -96,7 +96,7 @@ std::optional<std::string> HasNoNewUnconfirmed(const CTransaction& tx,
9696
}
9797

9898
for (unsigned int j = 0; j < tx.vin.size(); j++) {
99-
// BIP125 Rule #2: We don't want to accept replacements that require low feerate junk to be
99+
// Rule #2: We don't want to accept replacements that require low feerate junk to be
100100
// mined first. Ideally we'd keep track of the ancestor feerates and make the decision
101101
// based on that, but for now requiring all new inputs to be confirmed works.
102102
//
@@ -162,15 +162,15 @@ std::optional<std::string> PaysForRBF(CAmount original_fees,
162162
CFeeRate relay_fee,
163163
const uint256& txid)
164164
{
165-
// BIP125 Rule #3: The replacement fees must be greater than or equal to fees of the
165+
// Rule #3: The replacement fees must be greater than or equal to fees of the
166166
// transactions it replaces, otherwise the bandwidth used by those conflicting transactions
167167
// would not be paid for.
168168
if (replacement_fees < original_fees) {
169169
return strprintf("rejecting replacement %s, less fees than conflicting txs; %s < %s",
170170
txid.ToString(), FormatMoney(replacement_fees), FormatMoney(original_fees));
171171
}
172172

173-
// BIP125 Rule #4: The new transaction must pay for its own bandwidth. Otherwise, we have a DoS
173+
// Rule #4: The new transaction must pay for its own bandwidth. Otherwise, we have a DoS
174174
// vector where attackers can cause a transaction to be replaced (and relayed) repeatedly by
175175
// increasing the fee by tiny amounts.
176176
CAmount additional_fees = replacement_fees - original_fees;

src/policy/rbf.h

+14-14
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
class CFeeRate;
2020
class uint256;
2121

22-
/** Maximum number of transactions that can be replaced by BIP125 RBF (Rule #5). This includes all
22+
/** Maximum number of transactions that can be replaced by RBF Rule #5. This includes all
2323
* mempool conflicts and their descendants. */
2424
static constexpr uint32_t MAX_REPLACEMENT_CANDIDATES{100};
2525

@@ -47,24 +47,25 @@ enum class RBFTransactionState {
4747
RBFTransactionState IsRBFOptIn(const CTransaction& tx, const CTxMemPool& pool) EXCLUSIVE_LOCKS_REQUIRED(pool.cs);
4848
RBFTransactionState IsRBFOptInEmptyMempool(const CTransaction& tx);
4949

50-
/** Get all descendants of iters_conflicting. Also enforce BIP125 Rule #5, "The number of original
51-
* transactions to be replaced and their descendant transactions which will be evicted from the
52-
* mempool must not exceed a total of 100 transactions." Quit as early as possible. There cannot be
53-
* more than MAX_REPLACEMENT_CANDIDATES potential entries.
50+
/** Get all descendants of iters_conflicting. Checks that there are no more than
51+
* MAX_REPLACEMENT_CANDIDATES potential entries. May overestimate if the entries in
52+
* iters_conflicting have overlapping descendants.
5453
* @param[in] iters_conflicting The set of iterators to mempool entries.
5554
* @param[out] all_conflicts Populated with all the mempool entries that would be replaced,
56-
* which includes descendants of iters_conflicting. Not cleared at
57-
* the start; any existing mempool entries will remain in the set.
58-
* @returns an error message if Rule #5 is broken, otherwise a std::nullopt.
55+
* which includes iters_conflicting and all entries' descendants.
56+
* Not cleared at the start; any existing mempool entries will
57+
* remain in the set.
58+
* @returns an error message if MAX_REPLACEMENT_CANDIDATES may be exceeded, otherwise a std::nullopt.
5959
*/
6060
std::optional<std::string> GetEntriesForConflicts(const CTransaction& tx, CTxMemPool& pool,
6161
const CTxMemPool::setEntries& iters_conflicting,
6262
CTxMemPool::setEntries& all_conflicts)
6363
EXCLUSIVE_LOCKS_REQUIRED(pool.cs);
6464

65-
/** BIP125 Rule #2: "The replacement transaction may only include an unconfirmed input if that input
66-
* was included in one of the original transactions."
67-
* @returns error message if Rule #2 is broken, otherwise std::nullopt. */
65+
/** The replacement transaction may only include an unconfirmed input if that input was included in
66+
* one of the original transactions.
67+
* @returns error message if tx spends unconfirmed inputs not also spent by iters_conflicting,
68+
* otherwise std::nullopt. */
6869
std::optional<std::string> HasNoNewUnconfirmed(const CTransaction& tx, const CTxMemPool& pool,
6970
const CTxMemPool::setEntries& iters_conflicting)
7071
EXCLUSIVE_LOCKS_REQUIRED(pool.cs);
@@ -90,9 +91,8 @@ std::optional<std::string> EntriesAndTxidsDisjoint(const CTxMemPool::setEntries&
9091
std::optional<std::string> PaysMoreThanConflicts(const CTxMemPool::setEntries& iters_conflicting,
9192
CFeeRate replacement_feerate, const uint256& txid);
9293

93-
/** Enforce BIP125 Rule #3 "The replacement transaction pays an absolute fee of at least the sum
94-
* paid by the original transactions." Enforce BIP125 Rule #4 "The replacement transaction must also
95-
* pay for its own bandwidth at or above the rate set by the node's minimum relay fee setting."
94+
/** The replacement transaction must pay more fees than the original transactions. The additional
95+
* fees must pay for the replacement's bandwidth at or above the incremental relay feerate.
9696
* @param[in] original_fees Total modified fees of original transaction(s).
9797
* @param[in] replacement_fees Total modified fees of replacement transaction(s).
9898
* @param[in] replacement_vsize Total virtual size of replacement transaction(s).

src/rpc/mempool.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -690,7 +690,7 @@ static RPCHelpMan getmempoolinfo()
690690
{RPCResult::Type::NUM, "maxmempool", "Maximum memory usage for the mempool"},
691691
{RPCResult::Type::STR_AMOUNT, "mempoolminfee", "Minimum fee rate in " + CURRENCY_UNIT + "/kvB for tx to be accepted. Is the maximum of minrelaytxfee and minimum mempool fee"},
692692
{RPCResult::Type::STR_AMOUNT, "minrelaytxfee", "Current minimum relay fee for transactions"},
693-
{RPCResult::Type::NUM, "incrementalrelayfee", "minimum fee rate increment for mempool limiting or BIP 125 replacement in " + CURRENCY_UNIT + "/kvB"},
693+
{RPCResult::Type::NUM, "incrementalrelayfee", "minimum fee rate increment for mempool limiting or replacement in " + CURRENCY_UNIT + "/kvB"},
694694
{RPCResult::Type::NUM, "unbroadcastcount", "Current number of transactions that haven't passed initial broadcast yet"},
695695
{RPCResult::Type::BOOL, "fullrbf", "True if the mempool accepts RBF without replaceability signaling inspection"},
696696
}},

src/rpc/net.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -604,7 +604,7 @@ static RPCHelpMan getnetworkinfo()
604604
}},
605605
}},
606606
{RPCResult::Type::NUM, "relayfee", "minimum relay fee rate for transactions in " + CURRENCY_UNIT + "/kvB"},
607-
{RPCResult::Type::NUM, "incrementalfee", "minimum fee rate increment for mempool limiting or BIP 125 replacement in " + CURRENCY_UNIT + "/kvB"},
607+
{RPCResult::Type::NUM, "incrementalfee", "minimum fee rate increment for mempool limiting or replacement in " + CURRENCY_UNIT + "/kvB"},
608608
{RPCResult::Type::ARR, "localaddresses", "list of local addresses",
609609
{
610610
{RPCResult::Type::OBJ, "", "",

src/txmempool.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,7 @@ enum class MemPoolRemovalReason {
365365
* - a transaction which doesn't meet the minimum fee requirements.
366366
* - a new transaction that double-spends an input of a transaction already in
367367
* the pool where the new transaction does not meet the Replace-By-Fee
368-
* requirements as defined in BIP 125.
368+
* requirements as defined in doc/policy/mempool-replacements.md.
369369
* - a non-standard transaction.
370370
*
371371
* CTxMemPool::mapTx, and CTxMemPoolEntry bookkeeping:

src/validation.cpp

+6-6
Original file line numberDiff line numberDiff line change
@@ -862,8 +862,8 @@ bool MemPoolAccept::PreChecks(ATMPArgs& args, Workspace& ws)
862862
// Specifically, the subset of RBF transactions which we allow despite chain limits are those which
863863
// conflict directly with exactly one other transaction (but may evict children of said transaction),
864864
// and which are not adding any new mempool dependencies. Note that the "no new mempool dependencies"
865-
// check is accomplished later, so we don't bother doing anything about it here, but if BIP 125 is
866-
// amended, we may need to move that check to here instead of removing it wholesale.
865+
// check is accomplished later, so we don't bother doing anything about it here, but if our
866+
// policy changes, we may need to move that check to here instead of removing it wholesale.
867867
//
868868
// Such transactions are clearly not merging any existing packages, so we are only concerned with
869869
// ensuring that (a) no package is growing past the package size (not count) limits and (b) we are
@@ -930,7 +930,7 @@ bool MemPoolAccept::ReplacementChecks(Workspace& ws)
930930
TxValidationState& state = ws.m_state;
931931

932932
CFeeRate newFeeRate(ws.m_modified_fees, ws.m_vsize);
933-
// The replacement transaction must have a higher feerate than its direct conflicts.
933+
// Enforce Rule #6. The replacement transaction must have a higher feerate than its direct conflicts.
934934
// - The motivation for this check is to ensure that the replacement transaction is preferable for
935935
// block-inclusion, compared to what would be removed from the mempool.
936936
// - This logic predates ancestor feerate-based transaction selection, which is why it doesn't
@@ -943,18 +943,18 @@ bool MemPoolAccept::ReplacementChecks(Workspace& ws)
943943
return state.Invalid(TxValidationResult::TX_MEMPOOL_POLICY, "insufficient fee", *err_string);
944944
}
945945

946-
// Calculate all conflicting entries and enforce BIP125 Rule #5.
946+
// Calculate all conflicting entries and enforce Rule #5.
947947
if (const auto err_string{GetEntriesForConflicts(tx, m_pool, ws.m_iters_conflicting, ws.m_all_conflicting)}) {
948948
return state.Invalid(TxValidationResult::TX_MEMPOOL_POLICY,
949949
"too many potential replacements", *err_string);
950950
}
951-
// Enforce BIP125 Rule #2.
951+
// Enforce Rule #2.
952952
if (const auto err_string{HasNoNewUnconfirmed(tx, m_pool, ws.m_iters_conflicting)}) {
953953
return state.Invalid(TxValidationResult::TX_MEMPOOL_POLICY,
954954
"replacement-adds-unconfirmed", *err_string);
955955
}
956956
// Check if it's economically rational to mine this transaction rather than the ones it
957-
// replaces and pays for its own relay fees. Enforce BIP125 Rules #3 and #4.
957+
// replaces and pays for its own relay fees. Enforce Rules #3 and #4.
958958
for (CTxMemPool::txiter it : ws.m_all_conflicting) {
959959
ws.m_conflicting_fees += it->GetModifiedFee();
960960
ws.m_conflicting_size += it->GetTxSize();

src/validation.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ struct MempoolAcceptResult {
147147
const TxValidationState m_state;
148148

149149
// The following fields are only present when m_result_type = ResultType::VALID or MEMPOOL_ENTRY
150-
/** Mempool transactions replaced by the tx per BIP 125 rules. */
150+
/** Mempool transactions replaced by the tx. */
151151
const std::optional<std::list<CTransactionRef>> m_replaced_transactions;
152152
/** Virtual size as used by the mempool, calculated using serialized size and sigops. */
153153
const std::optional<int64_t> m_vsize;

src/wallet/feebumper.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,8 @@ static CFeeRate EstimateFeeRate(const CWallet& wallet, const CWalletTx& wtx, con
128128
// WALLET_INCREMENTAL_RELAY_FEE value to future proof against changes to
129129
// network wide policy for incremental relay fee that our node may not be
130130
// aware of. This ensures we're over the required relay fee rate
131-
// (BIP 125 rule 4). The replacement tx will be at least as large as the
132-
// original tx, so the total fee will be greater (BIP 125 rule 3)
131+
// (Rule 4). The replacement tx will be at least as large as the
132+
// original tx, so the total fee will be greater (Rule 3)
133133
CFeeRate node_incremental_relay_fee = wallet.chain().relayIncrementalFee();
134134
CFeeRate wallet_incremental_relay_fee = CFeeRate(WALLET_INCREMENTAL_RELAY_FEE);
135135
feerate += std::max(node_incremental_relay_fee, wallet_incremental_relay_fee);

src/wallet/rpc/spend.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ RPCHelpMan sendtoaddress()
224224
"transaction, just kept in your wallet."},
225225
{"subtractfeefromamount", RPCArg::Type::BOOL, RPCArg::Default{false}, "The fee will be deducted from the amount being sent.\n"
226226
"The recipient will receive less bitcoins than you enter in the amount field."},
227-
{"replaceable", RPCArg::Type::BOOL, RPCArg::DefaultHint{"wallet default"}, "Allow this transaction to be replaced by a transaction with higher fees via BIP 125"},
227+
{"replaceable", RPCArg::Type::BOOL, RPCArg::DefaultHint{"wallet default"}, "Signal that this transaction can replaced by a transaction (BIP 125)"},
228228
{"conf_target", RPCArg::Type::NUM, RPCArg::DefaultHint{"wallet -txconfirmtarget"}, "Confirmation target in blocks"},
229229
{"estimate_mode", RPCArg::Type::STR, RPCArg::Default{"unset"}, std::string() + "The fee estimate mode, must be one of (case insensitive):\n"
230230
" \"" + FeeModes("\"\n\"") + "\""},
@@ -333,7 +333,7 @@ RPCHelpMan sendmany()
333333
{"address", RPCArg::Type::STR, RPCArg::Optional::OMITTED, "Subtract fee from this address"},
334334
},
335335
},
336-
{"replaceable", RPCArg::Type::BOOL, RPCArg::DefaultHint{"wallet default"}, "Allow this transaction to be replaced by a transaction with higher fees via BIP 125"},
336+
{"replaceable", RPCArg::Type::BOOL, RPCArg::DefaultHint{"wallet default"}, "Signal that this transaction can replaced by a transaction (BIP 125)"},
337337
{"conf_target", RPCArg::Type::NUM, RPCArg::DefaultHint{"wallet -txconfirmtarget"}, "Confirmation target in blocks"},
338338
{"estimate_mode", RPCArg::Type::STR, RPCArg::Default{"unset"}, std::string() + "The fee estimate mode, must be one of (case insensitive):\n"
339339
" \"" + FeeModes("\"\n\"") + "\""},

src/wallet/wallet.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ static const CAmount DEFAULT_CONSOLIDATE_FEERATE{10000}; // 10 sat/vbyte
9090
static const CAmount DEFAULT_MAX_AVOIDPARTIALSPEND_FEE = 0;
9191
//! discourage APS fee higher than this amount
9292
constexpr CAmount HIGH_APS_FEE{COIN / 10000};
93-
//! minimum recommended increment for BIP 125 replacement txs
93+
//! minimum recommended increment for replacement txs
9494
static const CAmount WALLET_INCREMENTAL_RELAY_FEE = 5000;
9595
//! Default for -spendzeroconfchange
9696
static const bool DEFAULT_SPEND_ZEROCONF_CHANGE = true;
@@ -764,7 +764,7 @@ class CWallet final : public WalletStorage, public interfaces::Chain::Notificati
764764
/* Mark a transaction (and it in-wallet descendants) as abandoned so its inputs may be respent. */
765765
bool AbandonTransaction(const uint256& hashTx);
766766

767-
/** Mark a transaction as replaced by another transaction (e.g., BIP 125). */
767+
/** Mark a transaction as replaced by another transaction. */
768768
bool MarkReplaced(const uint256& originalHash, const uint256& newHash);
769769

770770
/* Initializes the wallet, returns a new CWallet instance or a null pointer in case of an error */

0 commit comments

Comments
 (0)