Return-Path: Received: from smtp2.osuosl.org (smtp2.osuosl.org [140.211.166.133]) by lists.linuxfoundation.org (Postfix) with ESMTP id B6271C000B for ; Mon, 7 Feb 2022 10:22:19 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id 84B2240272 for ; Mon, 7 Feb 2022 10:22:19 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org X-Spam-Flag: NO X-Spam-Score: -1.899 X-Spam-Level: X-Spam-Status: No, score=-1.899 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001] autolearn=ham autolearn_force=no Authentication-Results: smtp2.osuosl.org (amavisd-new); dkim=pass (2048-bit key) header.d=acinq-fr.20210112.gappssmtp.com Received: from smtp2.osuosl.org ([127.0.0.1]) by localhost (smtp2.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id TS9UVvXZ_lQW for ; Mon, 7 Feb 2022 10:22:14 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.8.0 Received: from mail-yb1-xb35.google.com (mail-yb1-xb35.google.com [IPv6:2607:f8b0:4864:20::b35]) by smtp2.osuosl.org (Postfix) with ESMTPS id 76233400AB for ; Mon, 7 Feb 2022 10:22:14 +0000 (UTC) Received: by mail-yb1-xb35.google.com with SMTP id g14so38311286ybs.8 for ; Mon, 07 Feb 2022 02:22:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=acinq-fr.20210112.gappssmtp.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=zWLy7JKVNmws7u0XGL5nLOGbHTLMQ2rM4GzVyi5/tlE=; b=qvJHAN8PAFmHDq6ystf/oTsyqDZqgoUzFAYDe0Hl+J9084bGEjHSJ888Zh3xf6r/ER n/cAUEoVSPQGXJ29iV8PicjNDFuEYdez3T53jo7I5OPRwVxMgwminp2qp+BkARjEmbs3 klBZRyuQsK4RnbdTi/Y9VNOfwgXl8oeIb5dmlYy7QjBcjUx4ecaZXYudmi1tiyCr6xDU uo0G66wzqjmcdOMXGE7DpZBScXClERFXFf8A6xlqqFRRiGsnTzRPUlybUdtgCwU6oowj /2H7C0OX5wybrKX7Z1ST2mB4J4v8ZAxXgwTtJTEUIRlPSdo1qizvTVl2/qIgMLI1NwuT EWrA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=zWLy7JKVNmws7u0XGL5nLOGbHTLMQ2rM4GzVyi5/tlE=; b=rP+fOvM+zE7/5A07PJBJ7UyOYDdXG2sP0sFmZNi/z6EjpKORzMzIz90izr9K12dL7K gPRkkyGug7yl4B7PEfhcR8evmowAEs32YMwmoilFW5ywJoJWC7iQteV2wKkWXSV9mmH0 JRJraz0BDIsebVMMgJOtjt2lz+7ZYBeo9L9SDSz5T53IY4HRsN7CU/szUrHOxCW1ln+W SwJMKuqLaSLGPVKSxcE0GS7l8CCjGj0MoSHgVRMzPwuJR8yv1+hchTYNr28SVv+tUpFb 0Y3n5XlgIGaFrrOOE/1yTQDEt9lIZRXV6gWamoLGXu6a4LuYEldYvQC+JlbSPCcX561F 3aFw== X-Gm-Message-State: AOAM533OX8GqzLLziogW3A0/qnc5bzCdOzKupz84zZqp+toSqJXPBe3C 7bRBvH0hfNWiI5YMNu7TLj2c85s2BcpzCo5VjB4c6w== X-Google-Smtp-Source: ABdhPJyQrrcTcV5/OuWJBZkEulhQzIbanLUxM0J7XUF+oI5MXK7Ew226LVjZ1QboRHaPyxINHSbIi4iMLdYDiUvWHcs= X-Received: by 2002:a05:6902:920:: with SMTP id bu32mr9492309ybb.693.1644229332905; Mon, 07 Feb 2022 02:22:12 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Bastien TEINTURIER Date: Mon, 7 Feb 2022 11:22:01 +0100 Message-ID: To: Michael Folkson , Anthony Towns Content-Type: multipart/alternative; boundary="00000000000051547405d76af9fa" X-Mailman-Approved-At: Mon, 07 Feb 2022 10:23:54 +0000 Cc: Bitcoin Protocol Discussion Subject: Re: [bitcoin-dev] Improving RBF Policy X-BeenThere: bitcoin-dev@lists.linuxfoundation.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Bitcoin Protocol Discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 07 Feb 2022 10:22:19 -0000 --00000000000051547405d76af9fa Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Good morning, > The tricky question is what happens when X arrives on its own and it > might be that no one ever sends a replacement for B,C,D) It feels ok to me, but this is definitely arguable. It covers the fact that B,C,D could have been fake transactions whose sole purpose was to do a pinning attack: in that case the attacker would have found a way to ensure these transactions don't confirm anyway (or pay minimal/negligible fees). If these transactions were legitimate, I believe that their owners would remake them at some point (because these transactions reflect a business relationship that needed to happen, so it should very likely still happen). It's probably hard to verify because the new corresponding transactions may have nothing in common with the first, but I think the simplifications it offers for wallets is worth it (which is just my opinion and needs more scrutiny/feedback). > But if your backlog's feerate does drop off, *and* that matters, then > I don't think you can ignore the impact of the descendent transactions > that you might not get a replacement for. That is because you're only taking into account the current backlog, and not taking into account the fact that new items will be added to it soon to replace the evicted descendants. But I agree that this is a bet: we can't predict the future and guarantee these replacements will come. It is really a trade-off, ignoring descendents provides a much simpler contract that doesn't vary from one mempool to another, but when your backlog isn't full enough, you may lose some future profits if transactions don't come in later. > I think "Y% higher" rather than just "higher" is only useful for > rate-limiting, not incentive compatibility. (Though maybe it helps > stabilise a greedy algorithm in some cases?) That's true. I claimed these policies only address incentives, but using a percentage increase addresses rate-limiting a bit as well (I couldn't resist trying to do at least something for it!). I find it a very easy mechanism to implement, while choosing an absolute value is hard (it's always easier to think in relatives than absolutes). > This is why I think it is important to understand the rationales for introducing the rules in the first place I completely agree. As you mentioned, we are still in brainstorming phase, once (if?) we start to converge on what could be better policies, we do need to clearly explain each policy's expected goal. That will let future Bastien writing code in 2030 clearly highlight why the 2022 rules don't make sense anymore! Cheers, Bastien Le sam. 5 f=C3=A9vr. 2022 =C3=A0 14:22, Michael Folkson a =C3=A9crit : > Thanks for this Bastien (and Gloria for initially posting about this). > > I sympathetically skimmed the eclair PR ( > https://github.com/ACINQ/eclair/pull/2113) dealing with replaceable > transactions fee bumping. > > There will continue to be a (hopefully) friendly tug of war on this > probably for the rest of Bitcoin's existence. I am sure people like Luke, > Prayank etc will (rightfully) continue to raise that Lightning and other > second layer protocols shouldn't demand that policy rules be changed if > there is a reason (e.g. DoS vector) for those rules on the base network. > But if there are rules that have no upside, introduce unnecessary > complexity for no reason and make Lightning implementers like Bastien's > life miserable attempting to deal with them I really hope we can make > progress on removing or simplifying them. > > This is why I think it is important to understand the rationales for > introducing the rules in the first place (and why it is safe to remove th= em > if indeed it is) and being as rigorous as possible on the rationales for > introducing additional rules. It sounds like from Gloria's initial post w= e > are still at a brainstorming phase (which is fine) but knowing what we kn= ow > today I really hope we can learn from the mistakes of the original BIP 12= 5, > namely the Core implementation not matching the BIP and the sparse > rationales for the rules. As Bastien says this is not criticizing the > original BIP 125 authors, 7 years is a long time especially in Bitcoin > world and they probably weren't thinking about Bastien sitting down to > write an eclair PR in late 2021 (and reviewers of that PR) when they wrot= e > the BIP in 2015. > > -- > Michael Folkson > Email: michaelfolkson at protonmail.com > Keybase: michaelfolkson > PGP: 43ED C999 9F85 1D40 EAF4 9835 92D6 0159 214C FEE3 > > > > ------- Original Message ------- > On Monday, January 31st, 2022 at 3:57 PM, Bastien TEINTURIER via > bitcoin-dev wrote: > > Hi Gloria, > > Many thanks for raising awareness on these issues and constantly pushing > towards finding a better model. This work will highly improve the > security of any multi-party contract trying to build on top of bitcoin > (because most multi-party contracts will need to have timeout conditions > and participants will need to make some transactions confirm before a > timeout happens - otherwise they may lose funds). > > For starters, let me quickly explain why the current rules are hard to > work with in the context of lightning (but I believe most L2 protocols > will have the same issues). Feel free to skip this part if you are > already convinced. > > ## Motivation > > The biggest pain point is BIP 125 rule 2. > If I need to increase the fees of a time-sensitive transaction because > the feerate has been rising since I broadcast it, I may need to also pay > high fees just to produce a confirmed utxo that I can use. I'm actually > paying a high fee twice instead of once (and needlessly using on-chain > space, our scarcest asset, because we could have avoided that additional > transaction!). > > It also has some annoying "non-determinism". > Imagine that my transaction has been evicted from my mempool because its > feerate was too low. I could think "Great, that means I don't have to > apply BIP 125 restrictions, I can just fund this transaction as if it > were a new one!". But actually I do, because my transaction could still > be in miner's mempools and I have no way of knowing it...this means that > whenever I have broadcast a transaction, I must assume that I will > always need to abide by whatever replacement rules the network applies. > > Fortunately, as far as I understand it, this rule only exists because of > a previous implementation detail of bitcoin core, so there's simply no > good reason to keep it. > > The second biggest pain point is rule 3. It prevents me from efficiently > using my capital while it's unconfirmed. Whenever I'm using a big utxo > to fund a transaction, I will get a big change output, and it would > really be a waste to be unable to use that change output to fund other > transactions. In order to be capital-efficient, I will end up creating > descendant trees for my time-sensitive transactions. But as Gloria > explained, replacing all my children will cost me an absurdly large > amount of fees. So what I'm actually planning to do instead is to RBF > one of the descendants high enough to get the whole tree confirmed. > But if those descendants' timeouts were far in the future, that's a > waste, I paid a lot more fees for them than I should have. I'd like to > just replace my transaction and republish the invalidated children > independently. > > Rule 4 doesn't hurt as much as the two previous ones, I don't have too > much to say about it. > > To be fair to the BIP 125 authors, all of these scenarios were very hard > to forecast at the time this BIP was created. We needed years to build > on those rules to get a better understanding of their limitations and if > the rationale behind them made sense in the long term. > > ## Proposals > > I believe that now is a good time to re-think those, and I really like > Gloria's categorization of the design constraints. > > I'd like to propose a different way of looking at descendants that makes > it easier to design the new rules. The way I understand it, limiting the > impact on descendant transactions is only important for DoS protection, > not for incentive compatibility. I would argue that after evictions, > descendant transactions will be submitted again (because they represent > transactions that people actually want to make), so evicting them does > not have a negative impact on mining incentives (in a world where blocks > are full most of the time). > > I'm curious to hear other people's thoughts on that. If it makes sense, > I would propose the following very simple rules: > > 1. The transaction's ancestor absolute fees must be X% higher than the > previous transaction's ancestor fees > 2. The transaction's ancestor feerate must be Y% higher than the > previous transaction's ancestor feerate > > I believe it's completely ok to require increasing both the fees and > feerate if we don't take descendants into account, because you control > your ancestor set - whereas the descendant set may be completely out of > your control. > > This is very easy to use by wallets, because the ancestor set is easy to > obtain. And an important point is that the ancestor set is the same in > every mempool, whereas the descendant set is not (your mempool may have > rejected the last descendants, while other people's mempools may still > contain them). > > Because of that reason, I'd like to avoid having a rule that relies on > some size of the replaced descendant set: it may be valid in your > mempool but invalid in someone else's, which makes it exploitable for > pinning attacks. > > I believe these rules are incentive compatible (again, if you accept > the fact that the descendants will be re-submitted and mined as well, > so their fees aren't lost). > > Can we choose X and Y so that these two rules are also DoS-resistant? > Unfortunately I'm not sure, so maybe we'll need to add a third rule to > address that. But before we do, can someone detail what it costs for a > node to evict a descendant tree? Given that bitcoin core doesn't allow > chains of more than 25 transactions, the maximum number of transactions > being replaced will be bounded by 25 * N (where N is the number of > outputs of the transaction being replaced). If it's just O(n) pruning of > a graph, maybe that's ok? Or maybe we make X or Y depend on the number > of outputs of the transaction being replaced (this would need very > careful thoughts)? > > If you made it this far, thanks for reading! > A couple of comments on the previous messages: > > > Currently, if we see a transaction > > that has the same txid as one in the mempool, we reject it as a > > duplicate, even if the feerate is much higher. It's unclear to me if > > we have a very strong reason to change this, but noting it as a > > limitation of our current replacement policy. > > I don't see a strong reason from an L2 protocol's point of view yet, but > there are many unkown unknowns. But from a miner incentive's point of > view, we should keep the transaction with the higher feerate, shouldn't > we? In that case it's also a more efficient use of on-chain space, which > is a win, right? > > > We might have a more-or-less long transition period during which we > support both... > > Yes, this is a long term thing. > Even if bitcoin core releases a new version with updated RBF rules, as a > wallet you'll need to keep using the old rules for a long time if you > want to be safe. > > But it's all the more reason to try to ship this as soon as possible, > this way maybe our grand-children will be able to benefit from it ;) > (just kidding on the timespan obviously). > > Cheers, > Bastien > > Le lun. 31 janv. 2022 =C3=A0 00:11, Antoine Riard via bitcoin-dev < > bitcoin-dev@lists.linuxfoundation.org> a =C3=A9crit : > >> Hi Gloria, >> >> Thanks for this RBF sum up. Few thoughts and more context comments if it >> can help other readers. >> >> > For starters, the absolute fee pinning attack is especially >> > problematic if we apply the same rules (i.e. Rule #3 and #4) in >> > Package RBF. Imagine that Alice (honest) and Bob (adversary) share a >> > LN channel. The mempool is rather full, so their pre-negotiated >> > commitment transactions' feerates would not be considered high >> > priority by miners. Bob broadcasts his commitment transaction and >> > attaches a very large child (100KvB with 100,000sat in fees) to his >> > anchor output. Alice broadcasts her commitment transaction with a >> > fee-bumping child (200vB with 50,000sat fees which is a generous >> > 250sat/vB), but this does not meet the absolute fee requirement. She >> > would need to add another 50,000sat to replace Bob's commitment >> > transaction. >> >> Solving LN pinning attacks, what we're aiming for is enabling a fair >> feerate bid between the counterparties, thus either forcing the adversar= y >> to overbid or to disengage from the confirmation competition. If the >> replace-by-feerate rule is adopted, there shouldn't be an incentive for = Bob >> to >> pick up the first option. Though if he does, that's a winning outcome fo= r >> Alice, as one of the commitment transactions confirms and her >> time-sensitive second-stage HTLC can be subsequently confirmed. >> >> > It's unclear to me if >> > we have a very strong reason to change this, but noting it as a >> > limitation of our current replacement policy. See [#24007][12]. >> >> Deployment of Taproot opens interesting possibilities in the >> vaults/payment channels design space, where the tapscripts can commit to >> different set of timelocks/quorum of keys. Even if the pre-signed states >> stay symmetric, whoever is the publisher, the feerate cost to spend can >> fluctuate. >> >> > While this isn't completely broken, and the user interface is >> > secondary to the safety of the mempool policy >> >> I think with L2s transaction broadcast backend, the stability and clarit= y >> of the RBF user interface is primary. What we could be worried about is = a >> too-much complex interface easing the way for an attacker to trigger you= r >> L2 node to issue policy-invalid chain of transactions. Especially, when = we >> consider that an attacker might have leverage on chain of transactions >> composition ("force broadcast of commitment A then commitment B, knowing >> they will share a CPFP") or even transactions size ("overload commitment= A >> with HTLCs"). >> >> > * If the original transaction is in the top {0.75MvB, 1MvB} of the >> > mempool, apply the current rules (absolute fees must increase and >> > pay for the replacement transaction's new bandwidth). Otherwise, use a >> > feerate-only rule. >> >> How this new replacement rule would behave if you have a parent in the >> "replace-by-feerate" half but the child is in the "replace-by-fee" one ? >> >> If we allow the replacement of the parent based on the feerate, we might >> decrease the top block absolute fees. >> >> If we block the replacement of the parent based on the feerate because >> the replacement absolute fees aren't above the replaced package, we stil= l >> preclude a pinning vector. The child might be low-feerate junk and even >> attached to a low ancestor-score branch. >> >> If I'm correct on this limitation, maybe we could turn off the >> "replace-by-fee" behavior as soon as the mempool is fulfilled with a few >> blocks ? >> >> > * Rate-limit how many replacements we allow per prevout. >> >> Depending on how it is implemented, though I would be concerned it >> introduces a new pinning vector in the context of shared-utxo. If it's a >> hardcoded constant, it could be exhausted by an adversary starting at th= e >> lowest acceptable feerate then slowly increasing while still not reachin= g >> the top of the mempool. Same if it's time-based or block-based, no >> guarantee the replacement slot is honestly used by your counterparty. >> >> Further, an above-the-average replacement frequency might just be the >> reflection of your confirmation strategy reacting to block schedule or >> mempools historical data. As long as the feerate penalty is paid, I lean= to >> allow replacement. >> >> (One solution could be to associate per-user "tag" to the LN >> transactions, where each "tag" would have its own replacement slots, but >> privacy?) >> >> > * Rate-limit transaction validation in general, per peer. >> >> I think we could improve on the Core's new transaction requester logic. >> Maybe we could bind the peer announced flow based on the feerate score >> (modulo validation time) of the previously validated transactions from t= hat >> peer ? That said, while related to RBF, it sounds to me that enhancing >> Core's rate-limiting transaction strategy is a whole discussion in itsel= f >> [0]. Especially ensuring it's tolerant to the specific requirements of L= N & >> consorts. >> >> > What should they be? We can do some arithmetic to see what happens if >> > you start with the biggest/lowest feerate transaction and do a bunch >> > of replacements. Maybe we end up with values that are high enough to >> > prevent abuse and make sense for applications/users that do RBF. >> >> That's a good question. >> >> One observation is that the attacker can always renew the set of DoSy >> utxos to pursue the attack. So maybe we could pick up constants scaled o= n >> the block size ? That way an attacker would have to burn fees, thus >> deterring them from launching an attack. Even if the attackers are miner= s, >> they have to renounce their income to acquire new DoSy utxos. If a low-f= ee >> period, we could scale up the constants ? >> >> >> Overall, I think there is the deployment issue to warn of. Moving to a >> new set of RBF rules implies for a lot of Bitcoin applications to rewrit= e >> their RBF logics. We might have a more-or-less long transition period >> during which we support both... >> >> Cheers, >> Antoine >> >> [0] https://github.com/bitcoin/bitcoin/pull/21224 >> >> Le jeu. 27 janv. 2022 =C3=A0 09:10, Gloria Zhao via bitcoin-dev < >> bitcoin-dev@lists.linuxfoundation.org> a =C3=A9crit : >> >>> Hi everyone, >>> >>> This post discusses limitations of current Bitcoin Core RBF policy and >>> attempts to start a conversation about how we can improve it, >>> summarizing some ideas that have been discussed. Please reply if you >>> have any new input on issues to be solved and ideas for improvement! >>> >>> Just in case I've screwed up the text wrapping again, another copy can = be >>> found here: >>> https://gist.github.com/glozow/25d9662c52453bd08b4b4b1d3783b9ff >>> >>> ## Background >>> >>> Please feel free to skip this section if you are already familiar >>> with RBF. >>> >>> Nodes may receive *conflicting* unconfirmed transactions, aka >>> "double spends" of the same inputs. Instead of always keeping the >>> first transaction, since v0.12, Bitcoin Core mempool policy has >>> included a set of Replace-by-Fee (RBF) criteria that allows the second >>> transaction to replace the first one and any descendants it may have. >>> >>> Bitcoin Core RBF policy was previously documented as BIP 125. >>> The current RBF policy is documented [here][1]. In summary: >>> >>> 1. The directly conflicting transactions all signal replaceability >>> explicitly. >>> >>> 2. The replacement transaction only includes an unconfirmed input if >>> that input was included in one of the directly conflicting >>> transactions. >>> >>> 3. The replacement transaction pays an absolute fee of at least the >>> sum paid by the original transactions. >>> >>> 4. The additional fees pays for the replacement transaction's >>> bandwidth at or above the rate set by the node's *incremental relay >>> feerate*. >>> >>> 5. The sum of all directly conflicting transactions' descendant counts >>> (number of transactions inclusive of itself and its descendants) >>> does not exceed 100. >>> >>> We can split these rules into 3 categories/goals: >>> >>> - **Allow Opting Out**: Some applications/businesses are unable to >>> handle transactions that are replaceable (e.g. merchants that use >>> zero-confirmation transactions). We (try to) help these businesses by >>> honoring BIP125 signaling; we won't replace transactions that have not >>> opted in. >>> >>> - **Incentive Compatibility**: Ensure that our RBF policy would not >>> accept replacement transactions which would decrease fee profits >>> of a miner. In general, if our mempool policy deviates from what is >>> economically rational, it's likely that the transactions in our >>> mempool will not match the ones in miners' mempools, making our >>> fee estimation, compact block relay, and other mempool-dependent >>> functions unreliable. Incentive-incompatible policy may also >>> encourage transaction submission through routes other than the p2p >>> network, harming censorship-resistance and privacy of Bitcoin payments. >>> >>> - **DoS Protection**: Limit two types of DoS attacks on the node's >>> mempool: (1) the number of times a transaction can be replaced and >>> (2) the volume of transactions that can be evicted during a >>> replacement. >>> >>> Even more abstract: our goal is to make a replacement policy that >>> results in a useful interface for users and safe policy for >>> node operators. >>> >>> ## Motivation >>> >>> There are a number of known problems with the current RBF policy. >>> Many of these shortcomings exist due to mempool limitations at the >>> time RBF was implemented or result from new types of Bitcoin usage; >>> they are not criticisms of the original design. >>> >>> ### Pinning Attacks >>> >>> The most pressing concern is that attackers may take advantage of >>> limitations in RBF policy to prevent other users' transactions from >>> being mined or getting accepted as a replacement. >>> >>> #### SIGHASH_ANYONECANPAY Pinning >>> >>> BIP125#2 can be bypassed by creating intermediary transactions to be >>> replaced together. Anyone can simply split a 1-input 1-output >>> transaction off from the replacement transaction, then broadcast the >>> transaction as is. This can always be done, and quite cheaply. More >>> details in [this comment][2]. >>> >>> In general, if a transaction is signed with SIGHASH\_ANYONECANPAY, >>> anybody can just attach a low feerate parent to this transaction and >>> lower its ancestor feerate. Even if you require SIGHASH\_ALL which >>> prevents an attacker from changing any outputs, the input can be a >>> very low amount (e.g. just above the dust limit) from a low-fee >>> ancestor and still bring down the ancestor feerate of the transaction. >>> >>> TLDR: if your transaction is signed with SIGHASH\_ANYONECANPAY and >>> signals replaceability, regardless of the feerate you broadcast at, an >>> attacker can lower its mining priority by adding an ancestor. >>> >>> #### Absolute Fee >>> >>> The restriction of requiring replacement transactions to increase the >>> absolute fee of the mempool has been described as "bonkers." If the >>> original transaction has a very large descendant that pays a large >>> amount of fees, even if it has a low feerate, the replacement >>> transaction must now pay those fees in order to meet Rule #3. >>> >>> #### Package RBF >>> >>> There are a number of reasons why, in order to enable Package RBF, we >>> cannot use the same criteria. >>> >>> For starters, the absolute fee pinning attack is especially >>> problematic if we apply the same rules (i.e. Rule #3 and #4) in >>> Package RBF. Imagine that Alice (honest) and Bob (adversary) share a >>> LN channel. The mempool is rather full, so their pre-negotiated >>> commitment transactions' feerates would not be considered high >>> priority by miners. Bob broadcasts his commitment transaction and >>> attaches a very large child (100KvB with 100,000sat in fees) to his >>> anchor output. Alice broadcasts her commitment transaction with a >>> fee-bumping child (200vB with 50,000sat fees which is a generous >>> 250sat/vB), but this does not meet the absolute fee requirement. She >>> would need to add another 50,000sat to replace Bob's commitment >>> transaction. >>> >>> Disallowing new unconfirmed inputs (Rule #2) in Package RBF would be >>> broken for packages containing transactions already in the mempool, >>> explained [here][7]. >>> >>> Note: I originally [proposed][6] Package RBF using the same Rule #3 >>> and #4 before I realized how significant this pinning attack is. I'm >>> retracting that proposal, and a new set of Package RBF rules would >>> follow from whatever the new individual RBF rules end up being. >>> >>> #### Same Txid Different Witness >>> >>> Two transactions with the same non-witness data but different >>> witnesses have the same txid but different wtxid, and the same fee but >>> not necessarily the same feerate. Currently, if we see a transaction >>> that has the same txid as one in the mempool, we reject it as a >>> duplicate, even if the feerate is much higher. It's unclear to me if >>> we have a very strong reason to change this, but noting it as a >>> limitation of our current replacement policy. See [#24007][12]. >>> >>> ### User Interface >>> >>> #### Using Unconfirmed UTXOs to Fund Replacements >>> >>> The restriction of only allowing confirmed UTXOs for funding a >>> fee-bump (Rule #2) can hurt users trying to fee-bump their >>> transactions and complicate wallet implementations. If the original >>> transaction's output value isn't sufficient to fund a fee-bump and/or >>> all of the user's other UTXOs are unconfirmed, they might not be able >>> to fund a replacement transaction. Wallet developers also need to >>> treat self-owned unconfirmed UTXOs as unusable for fee-bumping, which >>> adds complexity to wallet logic. For example, see BDK issues [#144][4] >>> and [#414][5]. >>> >>> #### Interface Not Suitable for Coin Selection >>> >>> Currently, a user cannot simply create a replacement transaction >>> targeting a specific feerate or meeting a minimum fee amount and >>> expect to meet the RBF criteria. The fee amount depends on the size of >>> the replacement transaction, and feerate is almost irrelevant. >>> >>> Bitcoin Core's `bumpfee` doesn't use the RBF rules when funding the >>> replacement. It [estimates][13] a feerate which is "wallet incremental >>> relay fee" (a conservative overestimation of the node's incremental >>> relay fee) higher than the original transaction, selects coins for >>> that feerate, and hopes that it meets the RBF rules. It never fails >>> Rule #3 and #4 because it uses all original inputs and refuses to >>> bump a transaction with mempool descendants. >>> >>> This is suboptimal, but is designed to work with the coin selection >>> engine: select a feerate first, and then add fees to cover it. >>> Following the exact RBF rules would require working the other way >>> around: based on how much fees we've added to the transaction and its >>> current size, calculate the feerate to see if we meet Rule #4. >>> >>> While this isn't completely broken, and the user interface is >>> secondary to the safety of the mempool policy, we can do much better. >>> A much more user-friendly interface would depend *only* on the >>> fee and size of the original transactions. >>> >>> ### Updates to Mempool and Mining >>> >>> Since RBF was first implemented, a number of improvements have been >>> made to mempool and mining logic. For example, we now use ancestor >>> feerates in mining (allowing CPFP), and keep track of ancestor >>> packages in the mempool. >>> >>> ## Ideas for Improvements >>> >>> ### Goals >>> >>> To summarize, these seem to be desired changes, in order of priority: >>> >>> 1. Remove Rule #3. The replacement should not be *required* to pay >>> higher absolute fees. >>> >>> 2. Make it impossible for a replacement transaction to have a lower >>> mining score than the original transaction(s). This would eliminate >>> the `SIGHASH\_ANYONECANPAY` pinning attack. >>> >>> 3. Remove Rule #2. Adding new unconfirmed inputs should be allowed. >>> >>> 4. Create a more helpful interface that helps wallet fund replacement >>> transactions that aim for a feerate and fee. >>> >>> ### A Different Model for Fees >>> >>> For incentive compatibility, I believe there are different >>> formulations we should consider. Most importantly, if we want to get >>> rid of the absolute fee rule, we can no longer think of it as "the >>> transaction needs to pay for its own bandwidth," since we won't always >>> be getting additional fees. That means we need a new method of >>> rate-limiting replacements that doesn't require additional fees every >>> time. >>> >>> While it makes sense to think about monetary costs when launching a >>> specific type of attack, given that the fees are paid to the miner and >>> not to the mempool operators, maybe it doesn't make much sense to >>> think about "paying for bandwidth". Maybe we should implement >>> transaction validation rate-limiting differently, e.g. building it >>> into the P2P layer instead of the mempool policy layer. >>> >>> Recently, Suhas gave a [formulation][8] for incentive compatibility >>> that made sense to me: "are the fees expected to be paid in the next >>> (N?) blocks higher or lower if we process this transaction?" >>> >>> I started by thinking about this where N=3D1 or `1 + p`. >>> Here, a rational miner is looking at what fees they would >>> collect in the next block, and then some proportion `p` of the rest of >>> the blocks based on their hashrate. We're assuming `p` isn't *so high* >>> that they would be okay with lower absolute fees in the next 1 block. >>> We're also assuming `p` isn't *so low* that the miner doesn't care >>> about what's left of the mempool after this block. >>> >>> A tweak to this formulation is "if we process this transaction, would >>> the fees in the next 1 block higher or lower, and is the feerate >>> density of the rest of the mempool higher or lower?" This is pretty >>> similar, where N=3D1, but we consider the rest of the mempool by feerat= e >>> rather than fees. >>> >>> ### Mining Score of a Mempool Transaction >>> >>> We are often interested in finding out what >>> the "mining score" of a transaction in the mempool is. That is, when >>> the transaction is considered in block template building, what is the >>> feerate it is considered at? >>> >>> Obviously, it's not the transaction's individual feerate. Bitcoin Core >>> [mining code sorts][14] transactions by their ancestor feerate and >>> includes them packages at a time, keeping track of how this affects the >>> package feerates of remaining transactions in the mempool. >>> >>> *ancestor feerate*: Ancestor feerate is easily accessible information, >>> but it's not accurate either, because it doesn't take into account the >>> fact that subsets of a transaction's ancestor set can be included >>> without it. For example, ancestors may have high feerates on their own >>> or we may have [high feerate siblings][8]. >>> >>> TLDR: *Looking at the current ancestor feerate of a transaction is >>> insufficient to tell us what feerate it will be considered at when >>> building a block template in the future.* >>> >>> *min(individual feerate, ancestor feerate)*: Another >>> heuristic that is simple to calculate based on current mempool tooling >>> is to use the [minimum of a transaction's individual score and its >>> ancestor score][10] as a conservative measure. But this can >>> overestimate as well (see the example below). >>> >>> *min ancestor feerate(tx + possible ancestor subsets)* We can also >>> take the minimum of every possible ancestor subset, but this can be >>> computationally expensive since there can be lots and lots of ancestor >>> subsets. >>> >>> *max ancestor feerate(tx + possible descendant subsets)*: Another idea >>> is to use the [maximum ancestor score of the transaction + each of its >>> descendants][9]. This doesn't work either; it has the same blindspot >>> of ancestor subsets being mined on their own. >>> >>> #### Mining Score Example >>> >>> Here's an example illustrating why mining score is tricky to >>> efficiently calculate for mempool transactions: >>> >>> Let's say you have same-size transactions A (21sat/vB), B (1sat/vB), >>> C(9sat/vB), D(5sat/vB). >>> The layout is: grandparent A, parent B, and two children C and D. >>> >>> ``` >>> A >>> ^ >>> B >>> ^ ^ >>> C D >>> ``` >>> >>> A miner using ancestor packages to build block templates will first >>> include A with a mining score of 21. Next, the miner will include B and >>> C with a mining score of 6. This leaves D, with a mining score of 5. >>> >>> Note: in this case, mining by ancestor feerate results in the most >>> rational decisions, but [a candidate set-based approach][10] which >>> makes ancestor feerate much less relevant could >>> be more advantageous in other situations. >>> >>> Here is a chart showing the "true" mining score alongside the values >>> calculating using imperfect heuristics described above. All of them >>> can overestimate or underestimate. >>> >>> ``` >>> A B C D >>> mining score | 21 | 6 | 6 | 5 | >>> ancestor feerate | 21 | 11 | 10.3 | 9 | >>> min(individual, ancestor) | 21 | 1 | 9 | 5 | >>> min(tx + ancestor subsets) | 21 | 1 | 5 | 3 | >>> max(tx + descendants subsets) | 21 | 9 | 9 | 5 | >>> >>> ``` >>> >>> Possibly the best solution for finding the "mining score" of a >>> transaction is to build a block template, see what feerate each >>> package is included at. Perhaps at some cutoff, remaining mempool >>> transactions can be estimated using some heuristic that leans >>> {overestimating, underestimating} depending on the situation. >>> >>> Mining score seems to be relevant in multiple places: Murch and I >>> recently [found][3] that it would be very important in >>> "ancestor-aware" funding of transactions (the wallet doesn't >>> incorporate ancestor fees when using unconfirmed transactions in coin >>> selection, which is a bug we want to fix). >>> >>> In general, it would be nice to know the exact mining priority of >>> one's unconfirmed transaction is. I can think of a few block/mempool >>> explorers who might want to display this information for users. >>> >>> ### RBF Improvement Proposals >>> >>> After speaking to quite a few people, here are some suggestions >>> for improvements that I have heard: >>> >>> * The ancestor score of the replacement must be {5, 10, N}% higher >>> than that of every original transaction. >>> >>> * The ancestor score of the replacement must be 1sat/vB higher than >>> that of every original transaction. >>> >>> * If the original transaction is in the top {0.75MvB, 1MvB} of the >>> mempool, apply the current rules (absolute fees must increase and >>> pay for the replacement transaction's new bandwidth). Otherwise, use a >>> feerate-only rule. >>> >>> * If fees don't increase, the size of the replacement transaction must >>> decrease by at least N%. >>> >>> * Rate-limit how many replacements we allow per prevout. >>> >>> * Rate-limit transaction validation in general, per peer. >>> >>> Perhaps some others on the mailing list can chime in to throw other >>> ideas into the ring and/or combine some of these rules into a sensible >>> policy. >>> >>> #### Replace by Feerate Only >>> >>> I don't think there's going to be a single-line feerate-based >>> rule that can incorporate everything we need. >>> On one hand, a feerate-only approach helps eliminate the issues >>> associated with Rule #3. On the other hand, I believe the main concern >>> with a feerate-only approach is how to rate limit replacements. We >>> don't want to enable an attack such as: >>> >>> 1. Attacker broadcasts large, low-feerate transaction, and attaches a >>> chain of descendants. >>> >>> 2. The attacker replaces the transaction with a smaller but higher >>> feerate transaction, attaching a new chain of descendants. >>> >>> 3. Repeat 1000 times. >>> >>> #### Fees in Next Block and Feerate for the Rest of the Mempool >>> >>> Perhaps we can look at replacements like this: >>> >>> 1. Calculate the directly conflicting transactions and, with their >>> descendants, the original transactions. Check signaling. Limit the >>> total volume (e.g. can't be more than 100 total or 1MvB or something). >>> >>> 2. Find which original transactions would be in the next ~1 block. The >>> replacement must pay at least this amount + X% in absolute fees. This >>> guarantees that the fees of the next block doesn't decrease. >>> >>> 3. Find which transactions would be left in the mempool after that ~1 >>> block. The replacement's feerate must be Y% higher than the maximum >>> mining score of these transactions. This guarantees that you now have >>> only *better* candidates in your after-this-block mempool than you did >>> before, even if the size and fees the transactions decrease. >>> >>> 4. Now you have two numbers: a minimum absolute fee amount and a >>> minimum feerate. Check to see if the replacement(s) meet these >>> minimums. Also, a wallet would be able to ask the node "What fee and >>> feerate would I need to put on a transaction replacing this?" and use >>> this information to fund a replacement transaction, without needing to >>> guess or overshoot. >>> >>> Obviously, there are some magic numbers missing here. X and Y are >>> TBD constants to ensure we have some kind of rate limiting for the >>> number of replacements allowed using some set of fees. >>> >>> What should they be? We can do some arithmetic to see what happens if >>> you start with the biggest/lowest feerate transaction and do a bunch >>> of replacements. Maybe we end up with values that are high enough to >>> prevent abuse and make sense for applications/users that do RBF. >>> >>> ### Mempool Changes Need for Implementation >>> >>> As described in the mining score section above, >>> we may want additional tooling to more accurately assess >>> the economic gain of replacing transactions in our mempool. >>> >>> A few options have been discussed: >>> >>> * Calculate block templates on the fly when we need to consider a >>> replacement. However, since replacements are [quite common][11] >>> and the information might be useful for other things as well, >>> it may be worth it to cache a block template. >>> >>> * Keep a persistent block template so that we know what transactions >>> we would put in the next block. We need to remember the feerate >>> at which each transaction was included in the template, because an >>> ancestor package may be included in the same block template in >>> multiple subsets. Transactions included earlier alter the ancestor >>> feerate of the remaining transactions in the package. We also need >>> to keep track of the new feerates of transactions left over. >>> >>> * Divide the mempool into two layers, "high feerate" and "low >>> feerate." The high feerate layer contains ~1 block of packages with >>> the highest ancestor feerates, and the low feerate layer contains >>> everything else. At the edge of a block, we have a Knapsacky problem >>> where the next highest ancestor feerate package might not fit, so we >>> would probably want the high feerate layer ~2MvB or something to avoid >>> underestimating the fees. >>> >>> ## Acknowledgements >>> >>> Thank you to everyone whose RBF-related suggestions, grievances, >>> criticisms and ideas were incorporated in this document: >>> Andrew Chow, Matt Corallo, Suhas Daftuar, Christian Decker, >>> Mark Erhardt, Lloyd Fournier, Lisa Neigut, John Newbery, >>> Antoine Poinsot, Antoine Riard, Larry Ruane, >>> S3RK and Bastien Teinturier. >>> >>> Thanks for reading! >>> >>> Best, >>> Gloria >>> >>> [1]: >>> https://github.com/bitcoin/bitcoin/blob/master/doc/policy/mempool-repla= cements.md >>> [2]: >>> https://github.com/bitcoin/bitcoin/pull/23121#issuecomment-929475999 >>> [3]: >>> https://github.com/Xekyo/bitcoin/commit/d754b0242ec69d42c570418aebf9c13= 35af0b8ea >>> [4]: https://github.com/bitcoindevkit/bdk/issues/144 >>> [5]: https://github.com/bitcoindevkit/bdk/issues/414 >>> [6]: >>> https://lists.linuxfoundation.org/pipermail/bitcoin-dev/2021-September/= 019464.html >>> [7]: >>> https://gist.github.com/glozow/dc4e9d5c5b14ade7cdfac40f43adb18a#new-unc= onfirmed-inputs-rule-2 >>> [8]: https://github.com/bitcoin/bitcoin/pull/23121#discussion_r77713136= 6 >>> [9]: >>> https://github.com/bitcoin/bitcoin/pull/22290#issuecomment-865887922 >>> [10]: >>> https://gist.github.com/Xekyo/5cb413fe9f26dbce57abfd344ebbfaf2#file-can= didate-set-based-block-building-md >>> [11]: >>> https://github.com/bitcoin/bitcoin/pull/22539#issuecomment-885763670 >>> [12]: https://github.com/bitcoin/bitcoin/pull/24007 >>> [13]: >>> https://github.com/bitcoin/bitcoin/blob/1a369f006fd0bec373b95001ed84b48= 0e852f191/src/wallet/feebumper.cpp#L114 >>> [14]: >>> https://github.com/bitcoin/bitcoin/blob/cf5bb048e80d4cde8828787b266b7f5= f2e3b6d7b/src/node/miner.cpp#L310-L320 >>> _______________________________________________ >>> bitcoin-dev mailing list >>> bitcoin-dev@lists.linuxfoundation.org >>> https://lists.linuxfoundation.org/mailman/listinfo/bitcoin-dev >>> >> _______________________________________________ >> bitcoin-dev mailing list >> bitcoin-dev@lists.linuxfoundation.org >> https://lists.linuxfoundation.org/mailman/listinfo/bitcoin-dev >> > > --00000000000051547405d76af9fa Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Good morning,

> The tricky que= stion is what happens when X arrives on its own and it
> might be tha= t no one ever sends a replacement for B,C,D)

It feels ok to me, but = this is definitely arguable.

It covers the fact that B,C,D could hav= e been fake transactions whose
sole purpose was to do a pinning attack: = in that case the attacker would
have found a way to ensure these transac= tions don't confirm anyway (or
pay minimal/negligible fees).

= If these transactions were legitimate, I believe that their owners wouldremake them at some point (because these transactions reflect a businessrelationship that needed to happen, so it should very likely still
hap= pen). It's probably hard to verify because the new corresponding
tra= nsactions may have nothing in common with the first, but I think the
sim= plifications it offers for wallets is worth it (which is just my
opinion= and needs more scrutiny/feedback).

> But if your backlog's f= eerate does drop off, *and* that matters, then
> I don't think yo= u can ignore the impact of the descendent transactions
> that you mig= ht not get a replacement for.

That is because you're only taking= into account the current backlog, and
not taking into account the fact = that new items will be added to it soon
to replace the evicted descendan= ts. But I agree that this is a bet: we
can't predict the future and = guarantee these replacements will come.

It is really a trade-off, ig= noring descendents provides a much simpler
contract that doesn't var= y from one mempool to another, but when your
backlog isn't full enou= gh, you may lose some future profits if
transactions don't come in l= ater.

> I think "Y% higher" rather than just "high= er" is only useful for
> rate-limiting, not incentive compatibil= ity. (Though maybe it helps
> stabilise a greedy algorithm in some ca= ses?)

That's true. I claimed these policies only address incenti= ves, but using
a percentage increase addresses rate-limiting a bit as we= ll (I couldn't
resist trying to do at least something for it!). I fi= nd it a very easy
mechanism to implement, while choosing an absolute val= ue is hard (it's
always easier to think in relatives than absolutes)= .

> This is why I think it is important to understand the rationa= les for introducing the rules in the first place

I completely agree.= As you mentioned, we are still in brainstorming
phase, once (if?) we st= art to converge on what could be better policies,
we do need to clearly = explain each policy's expected goal. That will let
future Bastien wr= iting code in 2030 clearly highlight why the 2022 rules
don't make s= ense anymore!

Cheers,
Bastien

Le=C2=A0sam. 5 f=C3=A9vr. 2022 =C3= =A0=C2=A014:22, Michael Folkson <michaelfolkson@protonmail.com> a =C3=A9crit=C2=A0:
Th= anks for this Bastien (and Gloria for initially posting about this).

I sympathetically skimmed the eclair PR (= htt= ps://github.com/ACINQ/eclair/pull/2113) dealing with replaceable transa= ctions fee bumping.

There will cont= inue to be a (hopefully) friendly tug of war on this probably for the rest = of Bitcoin's existence. I am sure people like Luke, Prayank etc will (r= ightfully) continue to raise that Lightning and other second layer protocol= s shouldn't demand that policy rules be changed if there is a reason (e= .g. DoS vector) for those rules on the base network. But if there are rules= that have no upside, introduce unnecessary complexity for no reason and ma= ke Lightning implementers like Bastien's life miserable attempting to d= eal with them I really hope we can make progress on removing or simplifying= them.=C2=A0

<= /div>
This is why I think it= is important to understand the rationales for introducing the rules in the= first place (and why it is safe to remove them if indeed it is) and being = as rigorous as possible on the rationales for introducing additional rules.= It sounds like from Gloria's initial post we are still at a brainstorm= ing phase (which is fine) but knowing what we know today I really hope we c= an learn from the mistakes of the original BIP 125, namely the Core impleme= ntation not matching the BIP and the sparse rationales for the rules. As Ba= stien says this is not criticizing the original BIP 125 authors, 7 years is= a long time especially in Bitcoin world and they probably weren't thin= king about Bastien sitting down to write an eclair PR in late 2021 (and rev= iewers of that PR) when they wrote the BIP in 2015.

--
Michael Fol= kson
Email: michaelfolkson at
protonmail.com
Keybase: michaelfolkson
PGP= : 43ED C999 9F85 1D40 EAF4 9835 92D6 0159 214C FEE3



------- Original Message -------
On Monday, January 31st, 2022 at 3:57 PM, Bastien TEINTURIER via bi= tcoin-dev <bitcoin-dev@lists.linuxfoundation.org> wrote:
Hi Gloria,

Many thanks for raising awar= eness on these issues and constantly pushing
towards finding a better mo= del. This work will highly improve the
security of any multi-party contr= act trying to build on top of bitcoin
(because most multi-party contract= s will need to have timeout conditions
and participants will need to mak= e some transactions confirm before a
timeout happens - otherwise they ma= y lose funds).

For starters, let me quickly explain why the current = rules are hard to
work with in the context of lightning (but I believe m= ost L2 protocols
will have the same issues). Feel free to skip this part= if you are
already convinced.

## Motivation

The biggest p= ain point is BIP 125 rule 2.
If I need to increase the fees of a time-se= nsitive transaction because
the feerate has been rising since I broadcas= t it, I may need to also pay
high fees just to produce a confirmed utxo = that I can use. I'm actually
paying a high fee twice instead of once= (and needlessly using on-chain
space, our scarcest asset, because we co= uld have avoided that additional
transaction!).

It also has some = annoying "non-determinism".
Imagine that my transaction has be= en evicted from my mempool because its
feerate was too low. I could thin= k "Great, that means I don't have to
apply BIP 125 restrictions= , I can just fund this transaction as if it
were a new one!". But a= ctually I do, because my transaction could still
be in miner's mempo= ols and I have no way of knowing it...this means that
whenever I have br= oadcast a transaction, I must assume that I will
always need to abide by= whatever replacement rules the network applies.

Fortunately, as far= as I understand it, this rule only exists because of
a previous impleme= ntation detail of bitcoin core, so there's simply no
good reason to = keep it.

The second biggest pain point is rule 3. It prevents me fro= m efficiently
using my capital while it's unconfirmed. Whenever I= 9;m using a big utxo
to fund a transaction, I will get a big change outp= ut, and it would
really be a waste to be unable to use that change outpu= t to fund other
transactions. In order to be capital-efficient, I will e= nd up creating
descendant trees for my time-sensitive transactions. But = as Gloria
explained, replacing all my children will cost me an absurdly = large
amount of fees. So what I'm actually planning to do instead is= to RBF
one of the descendants high enough to get the whole tree confirm= ed.
But if those descendants' timeouts were far in the future, that&= #39;s a
waste, I paid a lot more fees for them than I should have. I'= ;d like to
just replace my transaction and republish the invalidated chi= ldren
independently.

Rule 4 doesn't hurt as much as the two p= revious ones, I don't have too
much to say about it.

To be fa= ir to the BIP 125 authors, all of these scenarios were very hard
to fore= cast at the time this BIP was created. We needed years to build
on those= rules to get a better understanding of their limitations and if
the rat= ionale behind them made sense in the long term.

## Proposals

= I believe that now is a good time to re-think those, and I really like
G= loria's categorization of the design constraints.

I'd like t= o propose a different way of looking at descendants that makes
it easier= to design the new rules. The way I understand it, limiting the
impact o= n descendant transactions is only important for DoS protection,
not for = incentive compatibility. I would argue that after evictions,
descendant = transactions will be submitted again (because they represent
transaction= s that people actually want to make), so evicting them does
not have a n= egative impact on mining incentives (in a world where blocks
are full mo= st of the time).

I'm curious to hear other people's thoughts= on that. If it makes sense,
I would propose the following very simple r= ules:

1. The transaction's ancestor absolute fees must be X% hig= her than the
previous transaction's ancestor fees
2. The transact= ion's ancestor feerate must be Y% higher than the
previous transacti= on's ancestor feerate

I believe it's completely ok to requir= e increasing both the fees and
feerate if we don't take descendants = into account, because you control
your ancestor set - whereas the descen= dant set may be completely out of
your control.

This is very easy= to use by wallets, because the ancestor set is easy to
obtain. And an i= mportant point is that the ancestor set is the same in
every mempool, wh= ereas the descendant set is not (your mempool may have
rejected the last= descendants, while other people's mempools may still
contain them).=

Because of that reason, I'd like to avoid having a rule that re= lies on
some size of the replaced descendant set: it may be valid in you= r
mempool but invalid in someone else's, which makes it exploitable = for
pinning attacks.

I believe these rules are incentive compatib= le (again, if you accept
the fact that the descendants will be re-submit= ted and mined as well,
so their fees aren't lost).

Can we cho= ose X and Y so that these two rules are also DoS-resistant?
Unfortunatel= y I'm not sure, so maybe we'll need to add a third rule to
addre= ss that. But before we do, can someone detail what it costs for a
node t= o evict a descendant tree? Given that bitcoin core doesn't allow
cha= ins of more than 25 transactions, the maximum number of transactions
bei= ng replaced will be bounded by 25 * N (where N is the number of
outputs = of the transaction being replaced). If it's just O(n) pruning of
a g= raph, maybe that's ok? Or maybe we make X or Y depend on the number
= of outputs of the transaction being replaced (this would need very
caref= ul thoughts)?

If you made it this far, thanks for reading!
A coup= le of comments on the previous messages:

> Currently, if we see a= transaction
> that has the same txid as one in the mempool, we rejec= t it as a
> duplicate, even if the feerate is much higher. It's u= nclear to me if
> we have a very strong reason to change this, but no= ting it as a
> limitation of our current replacement policy.

I= don't see a strong reason from an L2 protocol's point of view yet,= but
there are many unkown unknowns. But from a miner incentive's po= int of
view, we should keep the transaction with the higher feerate, sho= uldn't
we? In that case it's also a more efficient use of on-cha= in space, which
is a win, right?

> We might have a more-or-les= s long transition period during which we support both...

Yes, this i= s a long term thing.
Even if bitcoin core releases a new version with up= dated RBF rules, as a
wallet you'll need to keep using the old rules= for a long time if you
want to be safe.

But it's all the m= ore reason to try to ship this as soon as possible,
this way maybe our g= rand-children will be able to benefit from it ;)
(just kidding on the ti= mespan obviously).

Cheers,
Bastien

Le lun. 31 janv. 20= 22 =C3=A0 00:11, Antoine Riard via bitcoin-dev <bitcoin-dev@lists.linuxfoundation.org> a =C3=A9crit :
=
Hi Gloria,

Thanks for this RBF sum up. Few thoughts and more co= ntext comments if it can help other readers.

> For starters, the = absolute fee pinning attack is especially
> problematic if we apply t= he same rules (i.e. Rule #3 and #4) in
> Package RBF. Imagine that Al= ice (honest) and Bob (adversary) share a
> LN channel. The mempool is= rather full, so their pre-negotiated
> commitment transactions' = feerates would not be considered high
> priority by miners. Bob broa= dcasts his commitment transaction and
> attaches a very large child (= 100KvB with 100,000sat in fees) to his
> anchor output. Alice broadca= sts her commitment transaction with a
> fee-bumping child (200vB with= 50,000sat fees which is a generous
> 250sat/vB), but this does not m= eet the absolute fee requirement. She
> would need to add another 50,= 000sat to replace Bob's commitment
> transaction.

Solving = LN pinning attacks, what we're aiming for is enabling a fair feerate bi= d between the counterparties, thus either forcing the adversary to overbid= or to disengage from the confirmation competition. If the replace-by-feera= te rule is adopted, there shouldn't be an incentive for Bob to
pick = up the first option. Though if he does, that's a winning outcome for Al= ice, as one of the commitment transactions confirms and her time-sensitive = second-stage HTLC can be subsequently confirmed.

> It's uncle= ar to me if
> we have a very strong reason to change this, but noting= it as a
> limitation of our current replacement policy. See [#24007]= [12].

Deployment of Taproot opens interesting possibilities in the v= aults/payment channels design space, where the tapscripts can commit to dif= ferent set of timelocks/quorum of keys. Even if the pre-signed states stay = symmetric, whoever is the publisher, the feerate cost to spend can fluctuat= e.

> While this isn't completely broken, and the user interfa= ce is
> secondary to the safety of the mempool policy

I think = with L2s transaction broadcast backend, the stability and clarity of the RB= F user interface is primary. What we could be worried about is a too-much c= omplex interface easing the way for an attacker to trigger your L2 node to = issue policy-invalid chain of transactions. Especially, when we consider th= at an attacker might have leverage on chain of transactions composition (&q= uot;force broadcast of commitment A then commitment B, knowing they will sh= are a CPFP") or even transactions size ("overload commitment A wi= th HTLCs").

> * If the original transaction is in the top {0= .75MvB, 1MvB} of the
> mempool, apply the current rules (absolute f= ees must increase and
> pay for the replacement transaction's new= bandwidth). Otherwise, use a
> feerate-only rule.

How this ne= w replacement rule would behave if you have a parent in the "replace-b= y-feerate" half but the child is in the "replace-by-fee" one= ?

If we allow the replacement of the parent based on the feerate, w= e might decrease the top block absolute fees.

If we block the replac= ement of the parent based on the feerate because the replacement absolute f= ees aren't above the replaced package, we still preclude a pinning vect= or. The child might be low-feerate junk and even attached to a low ancestor= -score branch.

If I'm correct on this limitation, maybe we could= turn off the "replace-by-fee" behavior as soon as the mempool is= fulfilled with a few blocks ?

> * Rate-limit how many replacemen= ts we allow per prevout.

Depending on how it is implemented, though = I would be concerned it introduces a new pinning vector in the context of s= hared-utxo. If it's a hardcoded constant, it could be exhausted by an a= dversary starting at the lowest acceptable feerate then slowly increasing w= hile still not reaching
the top of the mempool. Same if it's time-ba= sed or block-based, no guarantee the replacement slot is honestly used by y= our counterparty.

Further, an above-the-average replacement frequenc= y might just be the reflection of your confirmation strategy reacting to bl= ock schedule or mempools historical data. As long as the feerate penalty is= paid, I lean to allow replacement.

(One solution could be to = associate per-user "tag" to the LN transactions, where each "= ;tag" would have its own replacement slots, but privacy?)

= > * Rate-limit transaction validation in general, per peer.

I thi= nk we could improve on the Core's new transaction requester logic. Mayb= e we could bind the peer announced flow based on the feerate score (modulo = validation time) of the previously validated transactions from that peer ? = That said, while related to RBF, it sounds to me that enhancing Core's = rate-limiting transaction strategy is a whole discussion in itself [0]. Esp= ecially ensuring it's tolerant to the specific requirements of LN &= consorts.

> What should they be? We can do some arithmetic to se= e what happens if
> you start with the biggest/lowest feerate transac= tion and do a bunch
> of replacements. Maybe we end up with values th= at are high enough to
> prevent abuse and make sense for applications= /users that do RBF.

That's a good question.

One observat= ion is that the attacker can always renew the set of DoSy utxos to pursue t= he attack. So maybe we could pick up constants scaled on the block size ? T= hat way an attacker would have to burn fees, thus deterring them from launc= hing an attack. Even if the attackers are miners, they have to renounce the= ir income to acquire new DoSy utxos. If a low-fee period, we could scale up= the constants ?


Overall, I think there is the deployment issue = to warn of. Moving to a new set of RBF rules implies for a lot of Bitcoin a= pplications to rewrite their RBF logics. We might have a more-or-less long = transition period during which we support both...

Cheers,
Antoine=

[0] https://github.com/bitc= oin/bitcoin/pull/21224

Le jeu. 27 janv. 2022 =C3=A0 09:10, Glo= ria Zhao via bitcoin-dev <bitcoin-d= ev@lists.linuxfoundation.org> a =C3=A9crit :
Hi everyone,

Th= is post discusses limitations of current Bitcoin Core RBF policy and
att= empts to start a conversation about how we can improve it,
summarizing s= ome ideas that have been discussed. Please reply if you
have any new inp= ut on issues to be solved and ideas for improvement!

Just in case I&= #39;ve screwed up the text wrapping again, another copy can be
found her= e: https://gist.git= hub.com/glozow/25d9662c52453bd08b4b4b1d3783b9ff

## Background
Please feel free to skip this section if you are already familiar
w= ith RBF.

Nodes may receive *conflicting* unconfirmed transactions, a= ka
"double spends" of the same inputs. Instead of always keepi= ng the
first transaction, since v0.12, Bitcoin Core mempool policy hasincluded a set of Replace-by-Fee (RBF) criteria that allows the secondtransaction to replace the first one and any descendants it may have.
<= br>Bitcoin Core RBF policy was previously documented as BIP 125.
The cur= rent RBF policy is documented [here][1]. In summary:

1. The directly= conflicting transactions all signal replaceability
explicitly.
2. The replacement transaction only includes an unconfirmed input if
= that input was included in one of the directly conflicting
transaction= s.

3. The replacement transaction pays an absolute fee of at least t= he
sum paid by the original transactions.

4. The additional fe= es pays for the replacement transaction's
bandwidth at or above t= he rate set by the node's *incremental relay
feerate*.

5. The= sum of all directly conflicting transactions' descendant counts
= (number of transactions inclusive of itself and its descendants)
does no= t exceed 100.

We can split these rules into 3 categories/goals:
<= br>- **Allow Opting Out**: Some applications/businesses are unable to
= handle transactions that are replaceable (e.g. merchants that use
zero-c= onfirmation transactions). We (try to) help these businesses by
honoring= BIP125 signaling; we won't replace transactions that have not
opted= in.

- **Incentive Compatibility**: Ensure that our RBF policy would= not
accept replacement transactions which would decrease fee profits<= br> of a miner. In general, if our mempool policy deviates from what iseconomically rational, it's likely that the transactions in our
mem= pool will not match the ones in miners' mempools, making our
fee est= imation, compact block relay, and other mempool-dependent
functions unre= liable. Incentive-incompatible policy may also
encourage transaction sub= mission through routes other than the p2p
network, harming censorship-re= sistance and privacy of Bitcoin payments.

- **DoS Protection**: Limi= t two types of DoS attacks on the node's
mempool: (1) the number o= f times a transaction can be replaced and
(2) the volume of transactions= that can be evicted during a
replacement.

Even more abstract: ou= r goal is to make a replacement policy that
results in a useful interfac= e for users and safe policy for
node operators.

## Motivation
=
There are a number of known problems with the current RBF policy.
Ma= ny of these shortcomings exist due to mempool limitations at the
time RB= F was implemented or result from new types of Bitcoin usage;
they are no= t criticisms of the original design.

### Pinning Attacks

The = most pressing concern is that attackers may take advantage of
limitation= s in RBF policy to prevent other users' transactions from
being mine= d or getting accepted as a replacement.

#### SIGHASH_ANYONECANPAY Pi= nning

BIP125#2 can be bypassed by creating intermediary transactions= to be
replaced together. Anyone can simply split a 1-input 1-output
= transaction off from the replacement transaction, then broadcast the
tra= nsaction as is. This can always be done, and quite cheaply. More
details= in [this comment][2].

In general, if a transaction is signed with S= IGHASH\_ANYONECANPAY,
anybody can just attach a low feerate parent to th= is transaction and
lower its ancestor feerate. Even if you require SIGH= ASH\_ALL which
prevents an attacker from changing any outputs, the input= can be a
very low amount (e.g. just above the dust limit) from a low-fe= e
ancestor and still bring down the ancestor feerate of the transaction.=

TLDR: if your transaction is signed with SIGHASH\_ANYONECANPAY and<= br>signals replaceability, regardless of the feerate you broadcast at, anattacker can lower its mining priority by adding an ancestor.

####= Absolute Fee

The restriction of requiring replacement transactions = to increase the
absolute fee of the mempool has been described as "= bonkers." If the
original transaction has a very large descendant t= hat pays a large
amount of fees, even if it has a low feerate, the repla= cement
transaction must now pay those fees in order to meet Rule #3.
=
#### Package RBF

There are a number of reasons why, in order to = enable Package RBF, we
cannot use the same criteria.

For starters= , the absolute fee pinning attack is especially
problematic if we apply = the same rules (i.e. Rule #3 and #4) in
Package RBF. Imagine that Alice = (honest) and Bob (adversary) share a
LN channel. The mempool is rather f= ull, so their pre-negotiated
commitment transactions' feerates would= not be considered high
priority by miners. Bob broadcasts his commitme= nt transaction and
attaches a very large child (100KvB with 100,000sat i= n fees) to his
anchor output. Alice broadcasts her commitment transactio= n with a
fee-bumping child (200vB with 50,000sat fees which is a generou= s
250sat/vB), but this does not meet the absolute fee requirement. Shewould need to add another 50,000sat to replace Bob's commitment
tr= ansaction.

Disallowing new unconfirmed inputs (Rule #2) in Package R= BF would be
broken for packages containing transactions already in the m= empool,
explained [here][7].

Note: I originally [proposed][6] Pac= kage RBF using the same Rule #3
and #4 before I realized how significant= this pinning attack is. I'm
retracting that proposal, and a new set= of Package RBF rules would
follow from whatever the new individual RBF = rules end up being.

#### Same Txid Different Witness

Two tran= sactions with the same non-witness data but different
witnesses have the= same txid but different wtxid, and the same fee but
not necessarily the= same feerate. Currently, if we see a transaction
that has the same txid= as one in the mempool, we reject it as a
duplicate, even if the feerate= is much higher. It's unclear to me if
we have a very strong reason = to change this, but noting it as a
limitation of our current replacement= policy. See [#24007][12].

### User Interface

#### Using Unco= nfirmed UTXOs to Fund Replacements

The restriction of only allowing = confirmed UTXOs for funding a
fee-bump (Rule #2) can hurt users trying t= o fee-bump their
transactions and complicate wallet implementations. If = the original
transaction's output value isn't sufficient to fund= a fee-bump and/or
all of the user's other UTXOs are unconfirmed, th= ey might not be able
to fund a replacement transaction. Wallet developer= s also need to
treat self-owned unconfirmed UTXOs as unusable for fee-bu= mping, which
adds complexity to wallet logic. For example, see BDK issue= s [#144][4]
and [#414][5].

#### Interface Not Suitable for Coin S= election

Currently, a user cannot simply create a replacement transa= ction
targeting a specific feerate or meeting a minimum fee amount andexpect to meet the RBF criteria. The fee amount depends on the size ofthe replacement transaction, and feerate is almost irrelevant.

Bitc= oin Core's `bumpfee` doesn't use the RBF rules when funding the
= replacement. It [estimates][13] a feerate which is "wallet incremental=
relay fee" (a conservative overestimation of the node's increm= ental
relay fee) higher than the original transaction, selects coins for=
that feerate, and hopes that it meets the RBF rules. It never fails
= Rule #3 and #4 because it uses all original inputs and refuses to
bump a= transaction with mempool descendants.

This is suboptimal, but is de= signed to work with the coin selection
engine: select a feerate first, a= nd then add fees to cover it.
Following the exact RBF rules would requir= e working the other way
around: based on how much fees we've added t= o the transaction and its
current size, calculate the feerate to see if = we meet Rule #4.

While this isn't completely broken, and the use= r interface is
secondary to the safety of the mempool policy, we can do = much better.
A much more user-friendly interface would depend *only* on = the
fee and size of the original transactions.

### Updates to Mem= pool and Mining

Since RBF was first implemented, a number of improve= ments have been
made to mempool and mining logic. For example, we now us= e ancestor
feerates in mining (allowing CPFP), and keep track of ancesto= r
packages in the mempool.

## Ideas for Improvements

### G= oals

To summarize, these seem to be desired changes, in order of pri= ority:

1. Remove Rule #3. The replacement should not be *required* t= o pay
higher absolute fees.

2. Make it impossible for a replaceme= nt transaction to have a lower
mining score than the original transactio= n(s). This would eliminate
the `SIGHASH\_ANYONECANPAY` pinning attack.
3. Remove Rule #2. Adding new unconfirmed inputs should be allowed.
4. Create a more helpful interface that helps wallet fund replacement=
transactions that aim for a feerate and fee.

### A Different Mod= el for Fees

For incentive compatibility, I believe there are differe= nt
formulations we should consider. Most importantly, if we want to get=
rid of the absolute fee rule, we can no longer think of it as "the=
transaction needs to pay for its own bandwidth," since we won'= t always
be getting additional fees. That means we need a new method of<= br>rate-limiting replacements that doesn't require additional fees ever= y
time.

While it makes sense to think about monetary costs when l= aunching a
specific type of attack, given that the fees are paid to the = miner and
not to the mempool operators, maybe it doesn't make much s= ense to
think about "paying for bandwidth". Maybe we should im= plement
transaction validation rate-limiting differently, e.g. building = it
into the P2P layer instead of the mempool policy layer.

Recent= ly, Suhas gave a [formulation][8] for incentive compatibility
that made = sense to me: "are the fees expected to be paid in the next
(N?) blo= cks higher or lower if we process this transaction?"

I started = by thinking about this where N=3D1 or `1 + p`.
Here, a rational miner is= looking at what fees they would
collect in the next block, and then som= e proportion `p` of the rest of
the blocks based on their hashrate. We&#= 39;re assuming `p` isn't *so high*
that they would be okay with lowe= r absolute fees in the next 1 block.
We're also assuming `p` isn'= ;t *so low* that the miner doesn't care
about what's left of the= mempool after this block.

A tweak to this formulation is "if w= e process this transaction, would
the fees in the next 1 block higher or= lower, and is the feerate
density of the rest of the mempool higher or = lower?" This is pretty
similar, where N=3D1, but we consider the re= st of the mempool by feerate
rather than fees.

### Mining Score o= f a Mempool Transaction

We are often interested in finding out what<= br>the "mining score" of a transaction in the mempool is. That is= , when
the transaction is considered in block template building, what is= the
feerate it is considered at?

Obviously, it's not the tra= nsaction's individual feerate. Bitcoin Core
[mining code sorts][14] = transactions by their ancestor feerate and
includes them packages at a t= ime, keeping track of how this affects the
package feerates of remaining= transactions in the mempool.

*ancestor feerate*: Ancestor feerate i= s easily accessible information,
but it's not accurate either, becau= se it doesn't take into account the
fact that subsets of a transacti= on's ancestor set can be included
without it. For example, ancestors= may have high feerates on their own
or we may have [high feerate siblin= gs][8].

TLDR: *Looking at the current ancestor feerate of a transact= ion is
insufficient to tell us what feerate it will be considered at whe= n
building a block template in the future.*

*min(individual feera= te, ancestor feerate)*: Another
heuristic that is simple to calculate ba= sed on current mempool tooling
is to use the [minimum of a transaction&#= 39;s individual score and its
ancestor score][10] as a conservative meas= ure. But this can
overestimate as well (see the example below).
*min ancestor feerate(tx + possible ancestor subsets)* We can also
take= the minimum of every possible ancestor subset, but this can be
computat= ionally expensive since there can be lots and lots of ancestor
subsets.<= br>
*max ancestor feerate(tx + possible descendant subsets)*: Another id= ea
is to use the [maximum ancestor score of the transaction + each of it= s
descendants][9]. This doesn't work either; it has the same blindsp= ot
of ancestor subsets being mined on their own.

#### Mining Scor= e Example

Here's an example illustrating why mining score is tri= cky to
efficiently calculate for mempool transactions:

Let's = say you have same-size transactions A (21sat/vB), B (1sat/vB),
C(9sat/vB= ), D(5sat/vB).
The layout is: grandparent A, parent B, and two children = C and D.

```
A
^
B
^ ^
C D
```
A miner using ancestor packages to build block templates will firstinclude A with a mining score of 21. Next, the miner will include B andC with a mining score of 6. This leaves D, with a mining score of 5.
<= br>Note: in this case, mining by ancestor feerate results in the most
ra= tional decisions, but [a candidate set-based approach][10] which
makes a= ncestor feerate much less relevant could
be more advantageous in other s= ituations.

Here is a chart showing the "true" mining score= alongside the values
calculating using imperfect heuristics described a= bove. All of them
can overestimate or underestimate.

```
= A B C D
mining score | 21 | 6 | 6 | 5= |
ancestor feerate | 21 | 11 | 10.3 | 9 |
min(indiv= idual, ancestor) | 21 | 1 | 9 | 5 |
min(tx + ancestor su= bsets) | 21 | 1 | 5 | 3 |
max(tx + descendants subs= ets) | 21 | 9 | 9 | 5 |

```

Possibly the best= solution for finding the "mining score" of a
transaction is t= o build a block template, see what feerate each
package is included at. = Perhaps at some cutoff, remaining mempool
transactions can be estimated = using some heuristic that leans
{overestimating, underestimating} depend= ing on the situation.

Mining score seems to be relevant in multiple = places: Murch and I
recently [found][3] that it would be very important = in
"ancestor-aware" funding of transactions (the wallet doesn&= #39;t
incorporate ancestor fees when using unconfirmed transactions in c= oin
selection, which is a bug we want to fix).

In general, it wou= ld be nice to know the exact mining priority of
one's unconfirmed tr= ansaction is. I can think of a few block/mempool
explorers who might wa= nt to display this information for users.

### RBF Improvement Propos= als

After speaking to quite a few people, here are some suggestions<= br>for improvements that I have heard:

* The ancestor score of the r= eplacement must be {5, 10, N}% higher
than that of every original tran= saction.

* The ancestor score of the replacement must be 1sat/vB hig= her than
that of every original transaction.

* If the original = transaction is in the top {0.75MvB, 1MvB} of the
mempool, apply the cu= rrent rules (absolute fees must increase and
pay for the replacement tra= nsaction's new bandwidth). Otherwise, use a
feerate-only rule.
* If fees don't increase, the size of the replacement transaction mus= t
decrease by at least N%.

* Rate-limit how many replacements w= e allow per prevout.

* Rate-limit transaction validation in general,= per peer.

Perhaps some others on the mailing list can chime in to t= hrow other
ideas into the ring and/or combine some of these rules into a= sensible
policy.

#### Replace by Feerate Only

I don't= think there's going to be a single-line feerate-based
rule that can= incorporate everything we need.
On one hand, a feerate-only approach he= lps eliminate the issues
associated with Rule #3. On the other hand, I b= elieve the main concern
with a feerate-only approach is how to rate limi= t replacements. We
don't want to enable an attack such as:

1.= Attacker broadcasts large, low-feerate transaction, and attaches a
chai= n of descendants.

2. The attacker replaces the transaction with a sm= aller but higher
feerate transaction, attaching a new chain of descendan= ts.

3. Repeat 1000 times.

#### Fees in Next Block and Feerate= for the Rest of the Mempool

Perhaps we can look at replacements lik= e this:

1. Calculate the directly conflicting transactions and, with= their
descendants, the original transactions. Check signaling. Limit th= e
total volume (e.g. can't be more than 100 total or 1MvB or somethi= ng).

2. Find which original transactions would be in the next ~1 blo= ck. The
replacement must pay at least this amount + X% in absolute fees.= This
guarantees that the fees of the next block doesn't decrease.
3. Find which transactions would be left in the mempool after that ~1=
block. The replacement's feerate must be Y% higher than the maximum=
mining score of these transactions. This guarantees that you now haveonly *better* candidates in your after-this-block mempool than you didbefore, even if the size and fees the transactions decrease.

4. Now= you have two numbers: a minimum absolute fee amount and a
minimum feera= te. Check to see if the replacement(s) meet these
minimums. Also, a wall= et would be able to ask the node "What fee and
feerate would I need= to put on a transaction replacing this?" and use
this information = to fund a replacement transaction, without needing to
guess or overshoot= .

Obviously, there are some magic numbers missing here. X and Y are<= br>TBD constants to ensure we have some kind of rate limiting for the
nu= mber of replacements allowed using some set of fees.

What should the= y be? We can do some arithmetic to see what happens if
you start with th= e biggest/lowest feerate transaction and do a bunch
of replacements. May= be we end up with values that are high enough to
prevent abuse and make = sense for applications/users that do RBF.

### Mempool Changes Need f= or Implementation

As described in the mining score section above,we may want additional tooling to more accurately assess
the economic g= ain of replacing transactions in our mempool.

A few options have bee= n discussed:

* Calculate block templates on the fly when we need to = consider a
replacement. However, since replacements are [quite common]= [11]
and the information might be useful for other things as well, it may be worth it to cache a block template.

* Keep a persistent= block template so that we know what transactions
we would put in the = next block. We need to remember the feerate
at which each transaction wa= s included in the template, because an
ancestor package may be included = in the same block template in
multiple subsets. Transactions included ea= rlier alter the ancestor
feerate of the remaining transactions in the pa= ckage. We also need
to keep track of the new feerates of transactions le= ft over.

* Divide the mempool into two layers, "high feerate&q= uot; and "low
feerate." The high feerate layer contains ~1 b= lock of packages with
the highest ancestor feerates, and the low feerate= layer contains
everything else. At the edge of a block, we have a Knaps= acky problem
where the next highest ancestor feerate package might not f= it, so we
would probably want the high feerate layer ~2MvB or something = to avoid
underestimating the fees.

## Acknowledgements

Tha= nk you to everyone whose RBF-related suggestions, grievances,
criticisms= and ideas were incorporated in this document:
Andrew Chow, Matt Corallo= , Suhas Daftuar, Christian Decker,
Mark Erhardt, Lloyd Fournier, Lisa Ne= igut, John Newbery,
Antoine Poinsot, Antoine Riard, Larry Ruane,
S3RK and Bastien Teinturier.

Thanks for reading!<= /div>

Best,
Gloria

[1]: https:= //github.com/bitcoin/bitcoin/blob/master/doc/policy/mempool-replacements.md=
[2]: h= ttps://github.com/bitcoin/bitcoin/pull/23121#issuecomment-929475999
= [3]: https://github.com/Xekyo/bitcoin/commit/d754b0242ec69d42c570418aebf9c133= 5af0b8ea
[4]: https://github= .com/bitcoindevkit/bdk/issues/144
[5]: https://github.com/bitcoindevkit/bdk/issues/414
[6]: htt= ps://lists.linuxfoundation.org/pipermail/bitcoin-dev/2021-September/019464.= html
[7]: https://gist.github.com/glozow/dc4e9d5c5b14ade7= cdfac40f43adb18a#new-unconfirmed-inputs-rule-2
[8]: https://github.com/bitcoin/bitc= oin/pull/23121#discussion_r777131366
[9]: https://github.com/bitcoin/bitcoin/pull/= 22290#issuecomment-865887922
[10]: https://gi= st.github.com/Xekyo/5cb413fe9f26dbce57abfd344ebbfaf2#file-candidate-set-bas= ed-block-building-md
[11]: https://github.com/bitcoin/bitcoin/pull/22539#issuecomm= ent-885763670
[12]: https://gi= thub.com/bitcoin/bitcoin/pull/24007
[13]: https://github.com/bitcoin/bitcoin/blob/1a369f006fd0bec373b95001ed84b480e= 852f191/src/wallet/feebumper.cpp#L114
_______________________________________________
bitcoin-dev mailing list
bitcoin-dev@lists.linuxfoundation.org<= /a>
https://lists.linuxf= oundation.org/mailman/listinfo/bitcoin-dev
_______________________________________________
bitcoin-dev mailing list
bitcoin-dev@lists.linuxfoundation.org<= /a>
https://lists.linuxf= oundation.org/mailman/listinfo/bitcoin-dev

--00000000000051547405d76af9fa--