Skip to content

Commit c5f0cbe

Browse files
committed
Merge bitcoin#25775: docs: remove non-signaling mentions of BIP125
1dc03dd [doc] remove non-signaling mentions of BIP125 (glozow) 32024d4 scripted-diff: remove mention of BIP125 from non-signaling var names (glozow) Pull request description: We have pretty thorough documentation of our RBF policy in doc/policy/mempool-replacements.md. It enumerates each rule with several sentences of rationale. Also, each rule pretty much has its own function (3 and 4 share one), with extensive comments. The doc states explicitly that our rules are similar but differ from BIP125, and contains a record of historical changes to RBF policy. We should not use "BIP125" as synonymous with our RBF policy because: - Our RBF policy is different from what is specified in BIP125, for example: - the BIP does not mention our rule about the replacement feerate being higher (our Rule 6) - the BIP uses minimum relay feerate for Rule 4, while we have used incremental relay feerate since bitcoin#9380 - the "inherited signaling" question (CVE-2021-31876). Call it discrepancy, ambiguous wording, doc misinterpretation, or implementation details, I would recommend users refer to doc/policy/mempool-replacements.md - the signaling policy is configurable, see bitcoin#25353 - Our RBF policy may change further - We have already marked BIP125 as only "partially implemented" in docs/bips.md since 1fd49eb - See comments from people who are not me recently: - bitcoin#25038 (comment) - bitcoin#25575 (comment) This PR removes all non-signaling mentions of BIP125 (if people feel strongly, we can remove all mentions of BIP125 period). It may be useful to refer to the concept of "tx opts in to RBF if it has at least one nSequence less than (0xffffffff - 1)" as "BIP125 signaling" because: - It is succint. - It has already been widely marketed as BIP125 opt-in signaling. - Our API uses it when referring to signaling (e.g. getmempoolentry["bip125-replaceable"] and wallet error message "not BIP 125 replaceable"). Changing those is more invasive. - If/when we have other ways to signal in the future, we can disambiguate them this way. See bitcoin#25038 which proposes another way of signaling, and where I pulled these commits from. Alternatives: - Changing our policy to match BIP125. This doesn't make sense as, for example, we would have to remove the requirement that a replacement tx has a higher feerate (Rule 6). - Changing BIP125 to match what we have. This doesn't make sense as it would be a significant change to a BIP years after it was finalized and already used as a spec to implement RBF in other places. - Document our policy as a new BIP and give it a number. This might make sense if we don't expect things to change a lot, and can be done as a next step. ACKs for top commit: darosior: ACK 1dc03dd ariard: ACK 1dc03dd t-bast: ACK bitcoin@1dc03dd Tree-SHA512: a3adc2039ec5785892d230ec442e50f47f7062717392728152bbbe27ce1c564141f85253143f53cb44e1331cf47476d74f5d2f4b3cd873fc3433d7a0aa783e02
2 parents 607d5a4 + 1dc03dd commit c5f0cbe

File tree

15 files changed

+52
-52
lines changed

15 files changed

+52
-52
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
@@ -560,7 +560,7 @@ void SetupServerArgs(ArgsManager& argsman)
560560
SetupChainParamsBaseOptions(argsman);
561561

562562
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);
563-
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);
563+
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);
564564
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);
565565
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);
566566
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

+6-6
Original file line numberDiff line numberDiff line change
@@ -65,15 +65,15 @@ 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_BIP125_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.
72-
if (nConflictingCount > MAX_BIP125_REPLACEMENT_CANDIDATES) {
72+
if (nConflictingCount > MAX_REPLACEMENT_CANDIDATES) {
7373
return strprintf("rejecting replacement %s; too many potential replacements (%d > %d)\n",
7474
txid.ToString(),
7575
nConflictingCount,
76-
MAX_BIP125_REPLACEMENT_CANDIDATES);
76+
MAX_REPLACEMENT_CANDIDATES);
7777
}
7878
}
7979
// Calculate the set of all transactions that would have to be evicted.
@@ -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

+15-15
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@
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. */
24-
static constexpr uint32_t MAX_BIP125_REPLACEMENT_CANDIDATES{100};
24+
static constexpr uint32_t MAX_REPLACEMENT_CANDIDATES{100};
2525

2626
/** The rbf state of unconfirmed transactions */
2727
enum class RBFTransactionState {
@@ -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_BIP125_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
@@ -605,7 +605,7 @@ static RPCHelpMan getnetworkinfo()
605605
}},
606606
}},
607607
{RPCResult::Type::NUM, "relayfee", "minimum relay fee rate for transactions in " + CURRENCY_UNIT + "/kvB"},
608-
{RPCResult::Type::NUM, "incrementalfee", "minimum fee rate increment for mempool limiting or BIP 125 replacement in " + CURRENCY_UNIT + "/kvB"},
608+
{RPCResult::Type::NUM, "incrementalfee", "minimum fee rate increment for mempool limiting or replacement in " + CURRENCY_UNIT + "/kvB"},
609609
{RPCResult::Type::ARR, "localaddresses", "list of local addresses",
610610
{
611611
{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:

0 commit comments

Comments
 (0)