Over Half of Replace-by-Fee-Rate Replacements Are Mined

Over Half of Replace-by-Fee-Rate Replacements Are Mined
2024-02-24 17:55 ` Nagaev Boris
  
From: Peter Todd @ 2024-02-24 15:58 UTC (permalink / raw)
  To: bitcoindev

[-- Attachment #1: Type: text/plain, Size: 17855 bytes --]

Cross-post of a blog post article at https://petertodd.org/2024/replace-by-fee-rate-success-rate,
for the purpose of discussion.

---
layout: post
title:  "Over Half of Replace-by-Fee-Rate Replacements Are Mined"
date:   2024-02-24
tags:
- bitcoin
- rbf
- rbfr
---

I recently released a [prototype Libre Relay fork](https://github.com/petertodd/bitcoin/tree/libre-relay-v26.0) of Bitcoin Core v26.0, that among
other things, implements [Pure Replace-By-Fee-Rate](/2024/one-shot-replace-by-fee-rate#pure-replace-by-fee-rate) (RBFR)
with a 2x ratio. This means that transactions will be replaced if the fee-rate
of the new transaction is at least 2x higher than the old transaction(s), even
if the absolute fee is lower.

RBFR policies are highly desirable for Lightning and similar smart contract
systems as they have the potential to help solve pinning attacks, by ensuring
that it's always possible to make forward progress in a protocol by bidding a
fee rate sufficiently high to get mined in a short period of time. The only
question is whether or not some form of RBFR is feasible to implement.

Even though RBFR allows the total fee of a mempool to be reduced, one reason
why it is incentive compatible for miners is because it is likely that a RBFR
transaction will be mined by another miner anyway: mempools do *not* have
strict consensus, and miners mine transactions in what is essentially fee-rate
order. Thus it is likely that even without RBFR a higher fee-rate transaction
will be picked up by another miner, invalidating the lower fee-rate
transactions it conflicted with.

Here I'll present data showing this is in fact the case. At the moment, I have
no reason to believe that any miners have implemented RBFR. Yet, in the past
month, of the RBFR replacements seen by one of my well-connected Libre Relay
nodes, meeting the current 2x fee-rate requirement, at least 64% of those
replacements were mined by a variety of pools. This success rate suggests two
things:

1. By _not_ implementing RBFR, miners are leaving money on the table by failing to mine profitable transactions now, before other miners collect those fees.
2. Relaying RBFR replacements is a good use of relay bandwdith, because the majority of transactions are getting mined.

In conclusion, more nodes and miners should experiment with running RBFR, eg by
running Libre Relay.


## Limitations

This is a fairly limited data set: just 14 RBFR replacements in total over a 1
month period. Based on inspection of the transactions, they most likely
originate from a variety of different wallets in circumstances where one or
more transactions were replaced by a double-spend because the original
transaction(s) were of fee-rates too low to be quickly mined.

I only tried to analyze RBFR replacements in cases where the absolute fee
decreased. There are cases where the absolute fee can increase. Yet the
replacement is still RBFR as the fee was not increased *sufficiently* to be a
normal BIP125 RBF replacement. Due to how I was collecting logs, actually
finding those replacements isn't easy, so I didn't bother. Thus my count of 14
RBFR replacements is probably an underestimate.


## Data

The following is my actual notes that I used while analyzing the log file data
from my node:

```
Log start: Jan 23rd 2024
Log end: Feb 23rd 2024

grep replacing ~/.bitcoin/debug.log  |cut -d ' ' -f 11 | sort -n | head -n 50

2024-02-14T08:34:48Z [mempool] replacing tx 238459ee4e10b6ba6b8d4008c77d9bd2333ee1c81105f7be0e45497a6649c073 (wtxid=c328f7cca2aa3b3468d7cbf866138ff2a687125f91bee2cd1b653865f18dd5e3) with b8b7252047f5725531a9f1020f011e9d9b24d50ce2362fb5ef80a622b6f5280b (wtxid=1f987a7b85f958751803a276e631c16aa2704ecdf2cd70d32a8640483ba384b7) for -0.00022019 additional fees, -168 delta bytes
2024-02-14T08:34:48Z [mempool] replacing tx 71b0c8ca444b60bfb16a19bad8b399c2b5e9722865e00e713d47c65cf77728a3 (wtxid=d9f8dec57ff3905694691ea871897fa7e2011a6a7a95132a63fb4166942895b9) with b8b7252047f5725531a9f1020f011e9d9b24d50ce2362fb5ef80a622b6f5280b (wtxid=1f987a7b85f958751803a276e631c16aa2704ecdf2cd70d32a8640483ba384b7) for -0.00022019 additional fees, -168 delta bytes

outcome: unknown, as none of the transactions above were mined


2024-01-24T04:08:22Z [mempool] replacing tx c827e801a46db784892718bde7115fefda59dad3db095c75df820fc42ccf3916 (wtxid=c827e801a46db784892718bde7115fefda59dad3db095c75df820fc42ccf3916) with e053b6efef61bc76463fe1e916043b0aa84d2f8383c5b4efac7e70c279df4c2e (wtxid=e053b6efef61bc76463fe1e916043b0aa84d2f8383c5b4efac7e70c279df4c2e) for -0.00015576 additional fees, -1184 delta bytes
2024-01-24T04:08:22Z [mempool] replacing tx c5bb43f2411b4617677a73663f148a73478ab6c9d01362110784724542c4842d (wtxid=c5bb43f2411b4617677a73663f148a73478ab6c9d01362110784724542c4842d) with e053b6efef61bc76463fe1e916043b0aa84d2f8383c5b4efac7e70c279df4c2e (wtxid=e053b6efef61bc76463fe1e916043b0aa84d2f8383c5b4efac7e70c279df4c2e) for -0.00015576 additional fees, -1184 delta bytes
2024-01-24T04:08:22Z [mempool] replacing tx edbf7a134ec379938fc27dc3a4df0e4d145676dea818459af2653383ab49d574 (wtxid=edbf7a134ec379938fc27dc3a4df0e4d145676dea818459af2653383ab49d574) with e053b6efef61bc76463fe1e916043b0aa84d2f8383c5b4efac7e70c279df4c2e (wtxid=e053b6efef61bc76463fe1e916043b0aa84d2f8383c5b4efac7e70c279df4c2e) for -0.00015576 additional fees, -1184 delta bytes
2024-01-24T04:08:22Z [mempool] replacing tx 31b74b7375c966a9a27ee5ed9146e2913a2e55ac7ccee5c8bcc74be4048a97b6 (wtxid=31b74b7375c966a9a27ee5ed9146e2913a2e55ac7ccee5c8bcc74be4048a97b6) with e053b6efef61bc76463fe1e916043b0aa84d2f8383c5b4efac7e70c279df4c2e (wtxid=e053b6efef61bc76463fe1e916043b0aa84d2f8383c5b4efac7e70c279df4c2e) for -0.00015576 additional fees, -1184 delta bytes
2024-01-24T04:08:22Z [mempool] replacing tx e012768b6069c2e61a53cb31de293bcbefcb715c818e9b6b50e2034329ddbcee (wtxid=e012768b6069c2e61a53cb31de293bcbefcb715c818e9b6b50e2034329ddbcee) with e053b6efef61bc76463fe1e916043b0aa84d2f8383c5b4efac7e70c279df4c2e (wtxid=e053b6efef61bc76463fe1e916043b0aa84d2f8383c5b4efac7e70c279df4c2e) for -0.00015576 additional fees, -1184 delta bytes

outcome: e053b6efef61bc76463fe1e916043b0aa84d2f8383c5b4efac7e70c279df4c2e won, mined by f2pool; unclear how old replaced txs were


2024-02-10T01:48:15Z [mempool] replacing tx 6cff130587e5424ff11157ae4e84aa3a8b1663b591d77b0b3029258b65164274 (wtxid=028d3f85bac8aba30a2ab5c598f9dd511e5f3d6a8e8b03b01021b9b70ef60f1a) with 34debb7e99e0539d3671105aae44a6b06ae0b0b56907deb3232caa45ec75efc1 (wtxid=c85cf5b3cb64328dc455d8b2e62ba61ff48a34b7e3059128ef04b95b64b58683) for -0.00009301 additional fees, -481 delta bytes
2024-02-10T01:48:15Z [mempool] replacing tx 8a6c86e7e12af5905abafadbff8c9edd741e34f87559e53472c104504ab16e81 (wtxid=76e95ac81ad1ba5151687d4bb4309721746271284a4c563c79a201b2c90f0019) with 34debb7e99e0539d3671105aae44a6b06ae0b0b56907deb3232caa45ec75efc1 (wtxid=c85cf5b3cb64328dc455d8b2e62ba61ff48a34b7e3059128ef04b95b64b58683) for -0.00009301 additional fees, -481 delta bytes
2024-02-10T01:48:15Z [mempool] replacing tx a7258a7a5cef585f75bb9d67eb6f8a2bd832bb42e7a4cf962c37ea8c1a3ca3dd (wtxid=b3ab131da10e8de47459c4920aff4bc6cc5beb34249c41cdeb96b785d9632fac) with 34debb7e99e0539d3671105aae44a6b06ae0b0b56907deb3232caa45ec75efc1 (wtxid=c85cf5b3cb64328dc455d8b2e62ba61ff48a34b7e3059128ef04b95b64b58683) for -0.00009301 additional fees, -481 delta bytes
2024-02-10T01:48:15Z [mempool] replacing tx 624e6a56f8bd9acaf594a180d77fa2dad21ec0164f6496b1875af600e3d64cf2 (wtxid=26afba898925788e23781d509dd3918fca8b2cdeaf6ff06a65640cb639b5a1bd) with 34debb7e99e0539d3671105aae44a6b06ae0b0b56907deb3232caa45ec75efc1 (wtxid=c85cf5b3cb64328dc455d8b2e62ba61ff48a34b7e3059128ef04b95b64b58683) for -0.00009301 additional fees, -481 delta bytes

outcome: lost



2024-01-24T02:12:47Z [mempool] replacing tx 639ab332c1c257b04cffd3410199cb0af547e8ea9f7eeb29f9d0b4b24801680c (wtxid=639ab332c1c257b04cffd3410199cb0af547e8ea9f7eeb29f9d0b4b24801680c) with 281405690ccf1e6b3e18b37856fa60d5a66d7aae47577776ed8dcef73ce5d6c7 (wtxid=281405690ccf1e6b3e18b37856fa60d5a66d7aae47577776ed8dcef73ce5d6c7) for -0.00009195 additional fees, -976 delta bytes

outcome: 281405690ccf1e6b3e18b37856fa60d5a66d7aae47577776ed8dcef73ce5d6c7 won, mined by f2pool; replaced tx ~4 hours old


2024-01-23T22:57:15Z [mempool] replacing tx 54a33daa3eb300f2ea7261d6f4fdd026424aad3a9e65383b97576d70c59ff625 (wtxid=54a33daa3eb300f2ea7261d6f4fdd026424aad3a9e65383b97576d70c59ff625) with 867f9bf7e1aaec55f2a6552cb6e31ccce7c0aa75f9a08ae84c23960fc5951247 (wtxid=867f9bf7e1aaec55f2a6552cb6e31ccce7c0aa75f9a08ae84c23960fc5951247) for -0.00008978 additional fees, -326 delta bytes
2024-01-23T22:57:15Z [mempool] replacing tx 2cee5a3753ea4906677a749300ff95d00d4dfd9c1c49fb8ea42b6919e5b8075b (wtxid=e73f5cfaf6a6c5ec6fa68edcf2c741a2c9306bf85e1f2ed6d7424757aa0ceeff) with 867f9bf7e1aaec55f2a6552cb6e31ccce7c0aa75f9a08ae84c23960fc5951247 (wtxid=867f9bf7e1aaec55f2a6552cb6e31ccce7c0aa75f9a08ae84c23960fc5951247) for -0.00008978 additional fees, -326 delta bytes

outcome: lost


2024-02-08T02:53:17Z [mempool] replacing tx fdf726e40c61c9e78a4cbefcc38a9683b4a270020109ccc6584275d05dcffe88 (wtxid=793d89e1d27b1b001d485c277f2228a96674c6d15d21b012e84cffd89bb2f919) with 14b25c18e9ed920fac5e824ac92dc459f61abf89ea5a2c887b48bac4db4d5642 (wtxid=f8aac96aebdd5f4ed1094fae09bfe5be062e3e14f3907a94cc2573067137d764) for -0.00005916 additional fees, -180 delta bytes
2024-02-08T02:53:17Z [mempool] replacing tx 700179e09161b178f4346c296d28d1273a5b487a10e1dad6c90a763736fc40b6 (wtxid=b39281d543eacd32187b5b9b226dddfccdf33c6d979bfd8d58b73d5168d60968) with 14b25c18e9ed920fac5e824ac92dc459f61abf89ea5a2c887b48bac4db4d5642 (wtxid=f8aac96aebdd5f4ed1094fae09bfe5be062e3e14f3907a94cc2573067137d764) for -0.00005916 additional fees, -180 delta bytes

outcome: unclear, as fdf72 never got mined and don't have logs as to what it actually was


2024-02-14T08:33:03Z [mempool] replacing tx e16b43bfc2fb510ed2d7e5e4e89f94790f5f44ef6c643efe5eab1b12a30f016f (wtxid=7536fbdcfcfe3381be4f6bffed2ef68228615c1b29080029389cf6b29e0a4bd1) with 71b0c8ca444b60bfb16a19bad8b399c2b5e9722865e00e713d47c65cf77728a3 (wtxid=d9f8dec57ff3905694691ea871897fa7e2011a6a7a95132a63fb4166942895b9) for -0.0000588 additional fees, -168 delta bytes
2024-02-14T08:33:03Z [mempool] replacing tx b309997ea34321a16649bdb0998b1e6252aa48ed5f293ae1c251db6cd32dd9a5 (wtxid=b18d3e91956ddb7e78590aad4e3bdb25f5ec44e912ff96bacd5426c71f2b3f3d) with 71b0c8ca444b60bfb16a19bad8b399c2b5e9722865e00e713d47c65cf77728a3 (wtxid=d9f8dec57ff3905694691ea871897fa7e2011a6a7a95132a63fb4166942895b9) for -0.0000588 additional fees, -168 delta bytes

outcome: lost


2024-01-24T12:51:40Z [mempool] replacing tx 622d04cfa4b0c2da7ff52d787369139f14dfb7374ce8361636eeaf1ede0d1795 (wtxid=8107c0f45175d1cc07bf0fbf12ccd05bce2bd01adf9a75ff6fb20023fdb2b565) with 5c611198a41cb9f8ec9a44c3d66752312524dc265ee9ccbacf338dd14b202f8c (wtxid=b0567ae9a84f4467a6fe70f84de4dc89b9aec1aca156419b1463149055e7b27b) for -0.00005218 additional fees, -402 delta bytes
2024-01-24T12:51:40Z [mempool] replacing tx ded2f2189c2d6292104457d4d8006bb0e6f06b5be7c63fa3893bcd83059313a3 (wtxid=f43098191c4674c480ef2a278015561101043b815be484feb776b9e2a1cac9ed) with 5c611198a41cb9f8ec9a44c3d66752312524dc265ee9ccbacf338dd14b202f8c (wtxid=b0567ae9a84f4467a6fe70f84de4dc89b9aec1aca156419b1463149055e7b27b) for -0.00005218 additional fees, -402 delta bytes
2024-01-24T12:51:40Z [mempool] replacing tx ee09c7533f59ee69dc8bea7f1b63ea9b10ede7de3c2fb2ee0870b6160cac74ab (wtxid=30575e5c7d64222687febebd47124bbc25ec06ae90ebaf679ed120684fe73075) with 5c611198a41cb9f8ec9a44c3d66752312524dc265ee9ccbacf338dd14b202f8c (wtxid=b0567ae9a84f4467a6fe70f84de4dc89b9aec1aca156419b1463149055e7b27b) for -0.00005218 additional fees, -402 delta bytes
2024-01-24T12:51:40Z [mempool] replacing tx 04c4dd8ac5c9356e34aed870e9b221da2e358c904e6c8abecb1edc63b6808fdd (wtxid=e4f39d7cd0614b7e85b33e213989aed3376d4b78787081c2e6a3c32fb20bb5b8) with 5c611198a41cb9f8ec9a44c3d66752312524dc265ee9ccbacf338dd14b202f8c (wtxid=b0567ae9a84f4467a6fe70f84de4dc89b9aec1aca156419b1463149055e7b27b) for -0.00005218 additional fees, -402 delta bytes

outcome: 5c611198a41cb9f8ec9a44c3d66752312524dc265ee9ccbacf338dd14b202f8c won, mined by mara pool; unclear how old replaced txs were


2024-02-09T22:09:44Z [mempool] replacing tx ec5e68cc99d1184a5e01c92a01cee43104e09934eacb9489bd71039240b2409f (wtxid=0c179ced549a2ce013ecf75e210d6de43c5331d6c06c1593a2d7619216e2f6ae) with 1d25f2be63cad67c68528bfdcdf248fda1909dd7bef71f27a5fe9056ff9368b7 (wtxid=2d6e55531676b7b3b0dba67a9367f3f25536463c3e96c59b1c0b67945c4d90bc) for -0.00003893 additional fees, -1133 delta bytes

outcome: 1d25f2be63cad67c68528bfdcdf248fda1909dd7bef71f27a5fe9056ff9368b7 won, mined by f2pool; replaced tx was ~35 hours old


2024-02-15T15:00:13Z [mempool] replacing tx 4d4deb6e9170486724cdb0df8a1e4a1869d8b09c3e734a4781488a37417df8be (wtxid=4b65734a764b80cd80dccd26180ec7cba7463e66f347969c3b9ff450be8adfd7) with bbb06e7bd26e3010c9c0c8907850ac27aa7d842f8a888d757e41e1cf7c4f8cc0 (wtxid=88410651f659d234115180c959af0c958fb19e427cddd2b57c670c40fa37b59a) for -0.00003468 additional fees, -1487 delta bytes
2024-02-15T15:00:13Z [mempool] replacing tx 21696be674c6b02d013baf58f7f8f2bde8db6de17a8bc413714b69e3f2f9a0c8 (wtxid=b5d3e6f97bd695450fcb00731e69b2c4cf671508e17f5068cc4ee28e8d3edb42) with bbb06e7bd26e3010c9c0c8907850ac27aa7d842f8a888d757e41e1cf7c4f8cc0 (wtxid=88410651f659d234115180c959af0c958fb19e427cddd2b57c670c40fa37b59a) for -0.00003468 additional fees, -1487 delta bytes

outcome: bbb06e7bd26e3010c9c0c8907850ac27aa7d842f8a888d757e41e1cf7c4f8cc0 won, mined by f2pool; replaced txs were multiple days old


2024-02-04T16:11:10Z [mempool] replacing tx bfe8dbd86485710e0d562b8b4df58583aeb96f26beb180668f113127acffb3fb (wtxid=bac1485cc7cc99e46525c258fe682284e2ae9a9a650ea547a83719cab9cbc8c0) with 6cc0ea35c16a99828071d0ace21726c889cc920c6e4986b58c2e08ed0024787e (wtxid=51d23c0488460dd3e3db887c13a724eefdd2e0660d7abaf5ab598fe2334ddb15) for -0.00002919 additional fees, -360 delta bytes

outcome: 6cc0ea35c16a99828071d0ace21726c889cc920c6e4986b58c2e08ed0024787e won, mined by mara pool; replaced tx was ~13 hours old


2024-02-21T12:36:46Z [mempool] replacing tx 2a73fdfdb16a71f55ad6fb0e3165029c51b6b9247fdb88e0e44ad2bb432f8612 (wtxid=3fb092bf764450f3c90cc8856a578283a6586ecda5271004df0db4e65faab0a1) with 1a188e2d321f2b4a544a46843f9c0ce16bdd2cb40b560815297bfab506f53aa5 (wtxid=589dbfe1f80a569bd9253e61b88dfb8ea5e9305698a060bf68633852c75e596f) for -0.0000167 additional fees, -208 delta bytes
2024-02-21T12:36:46Z [mempool] replacing tx ace0e82d9b3df4a4571d2b764223626536fb4a21bb19eff110cbe235cacb8062 (wtxid=8f45a033255c246ecf67bef065ba9be1d4c38295aa0a2849f641c69b13123bfc) with 1a188e2d321f2b4a544a46843f9c0ce16bdd2cb40b560815297bfab506f53aa5 (wtxid=589dbfe1f80a569bd9253e61b88dfb8ea5e9305698a060bf68633852c75e596f) for -0.0000167 additional fees, -208 delta bytes

outcome: 1a188e2d321f2b4a544a46843f9c0ce16bdd2cb40b560815297bfab506f53aa5 won, mined by antpool; replaced txs only a few minutes old


2024-01-25T00:52:59Z [mempool] replacing tx 3bdd7b3c76cde41c0d8602a4d21c277350bc2f111f1ce1e543b6b49957c43244 (wtxid=3bdd7b3c76cde41c0d8602a4d21c277350bc2f111f1ce1e543b6b49957c43244) with d38eaf2d7a0a4443703a1f52804aadf2ded6c92bcd010ece323b7dea66427910 (wtxid=d38eaf2d7a0a4443703a1f52804aadf2ded6c92bcd010ece323b7dea66427910) for -0.00001142 additional fees, -191 delta bytes
2024-01-25T00:52:59Z [mempool] replacing tx 24c977c2306a56bb29734e97f1d5c674e324b090a108a267cd9a91ef84d8d671 (wtxid=24c977c2306a56bb29734e97f1d5c674e324b090a108a267cd9a91ef84d8d671) with d38eaf2d7a0a4443703a1f52804aadf2ded6c92bcd010ece323b7dea66427910 (wtxid=d38eaf2d7a0a4443703a1f52804aadf2ded6c92bcd010ece323b7dea66427910) for -0.00001142 additional fees, -191 delta bytes

outcome: d38eaf2d7a0a4443703a1f52804aadf2ded6c92bcd010ece323b7dea66427910 won, mined by mara pool; replaced txs ~20 minutes old


2024-02-20T01:11:00Z [mempool] replacing tx 2d58982eacae6acdebc719018de62669a8d47bdac068e8f48316406ab1ac4b03 (wtxid=f99e1001786a067d48045dc7abc7f3bc2cb98e9578f3dc1bb90fc93a004d6b47) with 9f5e001faf92b801eb626587f68986bf2ff1a8c3eddaa0d471d28bcdabe4af54 (wtxid=ab043f343c704f90af12a252b98cdf15c0e7adb2eb07abe9b8579ba13e4d3353) for -0.00000198 additional fees, -349 delta bytes
2024-02-20T01:11:00Z [mempool] replacing tx 300e937ea3617a99d1a9f0bcbdb7b51ad8785015e343e40822071653d913da2c (wtxid=253af0c23392ba028a8af719bdada8dc4aab0bcd6c4dd7b146a4b0717fd83d1c) with 9f5e001faf92b801eb626587f68986bf2ff1a8c3eddaa0d471d28bcdabe4af54 (wtxid=ab043f343c704f90af12a252b98cdf15c0e7adb2eb07abe9b8579ba13e4d3353) for -0.00000198 additional fees, -349 delta bytes
2024-02-20T01:11:00Z [mempool] replacing tx f758901698069d7649e02b50d7f96b6ade7f4d782a17fc7a5d0b4f95c7f595ea (wtxid=9a9f7d5398f9f56d113448cab25dfd17714727fc4f912b3a72f36d4ef005b1d6) with 9f5e001faf92b801eb626587f68986bf2ff1a8c3eddaa0d471d28bcdabe4af54 (wtxid=ab043f343c704f90af12a252b98cdf15c0e7adb2eb07abe9b8579ba13e4d3353) for -0.00000198 additional fees, -349 delta bytes

outcome: 9f5e001faf92b801eb626587f68986bf2ff1a8c3eddaa0d471d28bcdabe4af54 won, mined by sbi crypto; replaced txs were many hours old

total: 14
unclear: 2
lost: 3
rbfr mined: 9

total rbfr mined: 64%
```

-- 
https://petertodd.org 'peter'[:-1]@petertodd.org

-- 
asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

 permalink raw reply	[|nested]
2024-02-24 15:58 [bitcoindev] Over Half of Replace-by-Fee-Rate Replacements Are Mined Peter Todd

  2024-02-24 18:45   ` Peter Todd
  
From: Nagaev Boris @ 2024-02-24 17:55 UTC (permalink / raw)
  To: Peter Todd;  bitcoindev

Hi Peter,

On Sat, Feb 24, 2024 at 1:21 PM Peter Todd <pete@petertodd•org> wrote:
>
> Cross-post of a blog post article at https://petertodd.org/2024/replace-by-fee-rate-success-rate,
> for the purpose of discussion.
>
> ---
> layout: post
> title:  "Over Half of Replace-by-Fee-Rate Replacements Are Mined"
> date:   2024-02-24
> tags:
> - bitcoin
> - rbf
> - rbfr
> ---
>
> I recently released a [prototype Libre Relay fork](https://github.com/petertodd/bitcoin/tree/libre-relay-v26.0) of Bitcoin Core v26.0, that among
> other things, implements [Pure Replace-By-Fee-Rate](/2024/one-shot-replace-by-fee-rate#pure-replace-by-fee-rate) (RBFR)
> with a 2x ratio. This means that transactions will be replaced if the fee-rate
> of the new transaction is at least 2x higher than the old transaction(s), even
> if the absolute fee is lower.

I like the idea of pure replacement by fee rate, but I'm not sure
about the 2x coefficient. I'm afraid it can result in overpaying.

What is the purpose of the 2x coefficient? Is it needed to prevent DoS
by continuously increasing feerate by a fraction of a percent? Isn't
1.1x enough to prevent this DoS vector? A rise from 100 sats/byte to
110 sats/byte is easier to bear, then a rise from 100 to 200,
especially if the next block feerate is 105.

> RBFR policies are highly desirable for Lightning and similar smart contract
> systems as they have the potential to help solve pinning attacks, by ensuring
> that it's always possible to make forward progress in a protocol by bidding a
> fee rate sufficiently high to get mined in a short period of time. The only
> question is whether or not some form of RBFR is feasible to implement.
>
> Even though RBFR allows the total fee of a mempool to be reduced, one reason
> why it is incentive compatible for miners is because it is likely that a RBFR
> transaction will be mined by another miner anyway: mempools do *not* have
> strict consensus, and miners mine transactions in what is essentially fee-rate
> order. Thus it is likely that even without RBFR a higher fee-rate transaction
> will be picked up by another miner, invalidating the lower fee-rate
> transactions it conflicted with.
>
> Here I'll present data showing this is in fact the case. At the moment, I have
> no reason to believe that any miners have implemented RBFR. Yet, in the past
> month, of the RBFR replacements seen by one of my well-connected Libre Relay
> nodes, meeting the current 2x fee-rate requirement, at least 64% of those
> replacements were mined by a variety of pools. This success rate suggests two
> things:
>
> 1. By _not_ implementing RBFR, miners are leaving money on the table by failing to mine profitable transactions now, before other miners collect those fees.
> 2. Relaying RBFR replacements is a good use of relay bandwdith, because the majority of transactions are getting mined.
>
> In conclusion, more nodes and miners should experiment with running RBFR, eg by
> running Libre Relay.
>
>
> ## Limitations
>
> This is a fairly limited data set: just 14 RBFR replacements in total over a 1
> month period. Based on inspection of the transactions, they most likely
> originate from a variety of different wallets in circumstances where one or
> more transactions were replaced by a double-spend because the original
> transaction(s) were of fee-rates too low to be quickly mined.
>
> I only tried to analyze RBFR replacements in cases where the absolute fee
> decreased. There are cases where the absolute fee can increase. Yet the
> replacement is still RBFR as the fee was not increased *sufficiently* to be a
> normal BIP125 RBF replacement. Due to how I was collecting logs, actually
> finding those replacements isn't easy, so I didn't bother. Thus my count of 14
> RBFR replacements is probably an underestimate.
>
>
> ## Data
>
> The following is my actual notes that I used while analyzing the log file data
> from my node:
>
> ```
> Log start: Jan 23rd 2024
> Log end: Feb 23rd 2024
>
> grep replacing ~/.bitcoin/debug.log  |cut -d ' ' -f 11 | sort -n | head -n 50
>
> 2024-02-14T08:34:48Z [mempool] replacing tx 238459ee4e10b6ba6b8d4008c77d9bd2333ee1c81105f7be0e45497a6649c073 (wtxid=c328f7cca2aa3b3468d7cbf866138ff2a687125f91bee2cd1b653865f18dd5e3) with b8b7252047f5725531a9f1020f011e9d9b24d50ce2362fb5ef80a622b6f5280b (wtxid=1f987a7b85f958751803a276e631c16aa2704ecdf2cd70d32a8640483ba384b7) for -0.00022019 additional fees, -168 delta bytes
> 2024-02-14T08:34:48Z [mempool] replacing tx 71b0c8ca444b60bfb16a19bad8b399c2b5e9722865e00e713d47c65cf77728a3 (wtxid=d9f8dec57ff3905694691ea871897fa7e2011a6a7a95132a63fb4166942895b9) with b8b7252047f5725531a9f1020f011e9d9b24d50ce2362fb5ef80a622b6f5280b (wtxid=1f987a7b85f958751803a276e631c16aa2704ecdf2cd70d32a8640483ba384b7) for -0.00022019 additional fees, -168 delta bytes
>
> outcome: unknown, as none of the transactions above were mined
>
>
> 2024-01-24T04:08:22Z [mempool] replacing tx c827e801a46db784892718bde7115fefda59dad3db095c75df820fc42ccf3916 (wtxid=c827e801a46db784892718bde7115fefda59dad3db095c75df820fc42ccf3916) with e053b6efef61bc76463fe1e916043b0aa84d2f8383c5b4efac7e70c279df4c2e (wtxid=e053b6efef61bc76463fe1e916043b0aa84d2f8383c5b4efac7e70c279df4c2e) for -0.00015576 additional fees, -1184 delta bytes
> 2024-01-24T04:08:22Z [mempool] replacing tx c5bb43f2411b4617677a73663f148a73478ab6c9d01362110784724542c4842d (wtxid=c5bb43f2411b4617677a73663f148a73478ab6c9d01362110784724542c4842d) with e053b6efef61bc76463fe1e916043b0aa84d2f8383c5b4efac7e70c279df4c2e (wtxid=e053b6efef61bc76463fe1e916043b0aa84d2f8383c5b4efac7e70c279df4c2e) for -0.00015576 additional fees, -1184 delta bytes
> 2024-01-24T04:08:22Z [mempool] replacing tx edbf7a134ec379938fc27dc3a4df0e4d145676dea818459af2653383ab49d574 (wtxid=edbf7a134ec379938fc27dc3a4df0e4d145676dea818459af2653383ab49d574) with e053b6efef61bc76463fe1e916043b0aa84d2f8383c5b4efac7e70c279df4c2e (wtxid=e053b6efef61bc76463fe1e916043b0aa84d2f8383c5b4efac7e70c279df4c2e) for -0.00015576 additional fees, -1184 delta bytes
> 2024-01-24T04:08:22Z [mempool] replacing tx 31b74b7375c966a9a27ee5ed9146e2913a2e55ac7ccee5c8bcc74be4048a97b6 (wtxid=31b74b7375c966a9a27ee5ed9146e2913a2e55ac7ccee5c8bcc74be4048a97b6) with e053b6efef61bc76463fe1e916043b0aa84d2f8383c5b4efac7e70c279df4c2e (wtxid=e053b6efef61bc76463fe1e916043b0aa84d2f8383c5b4efac7e70c279df4c2e) for -0.00015576 additional fees, -1184 delta bytes
> 2024-01-24T04:08:22Z [mempool] replacing tx e012768b6069c2e61a53cb31de293bcbefcb715c818e9b6b50e2034329ddbcee (wtxid=e012768b6069c2e61a53cb31de293bcbefcb715c818e9b6b50e2034329ddbcee) with e053b6efef61bc76463fe1e916043b0aa84d2f8383c5b4efac7e70c279df4c2e (wtxid=e053b6efef61bc76463fe1e916043b0aa84d2f8383c5b4efac7e70c279df4c2e) for -0.00015576 additional fees, -1184 delta bytes
>
> outcome: e053b6efef61bc76463fe1e916043b0aa84d2f8383c5b4efac7e70c279df4c2e won, mined by f2pool; unclear how old replaced txs were
>
>
> 2024-02-10T01:48:15Z [mempool] replacing tx 6cff130587e5424ff11157ae4e84aa3a8b1663b591d77b0b3029258b65164274 (wtxid=028d3f85bac8aba30a2ab5c598f9dd511e5f3d6a8e8b03b01021b9b70ef60f1a) with 34debb7e99e0539d3671105aae44a6b06ae0b0b56907deb3232caa45ec75efc1 (wtxid=c85cf5b3cb64328dc455d8b2e62ba61ff48a34b7e3059128ef04b95b64b58683) for -0.00009301 additional fees, -481 delta bytes
> 2024-02-10T01:48:15Z [mempool] replacing tx 8a6c86e7e12af5905abafadbff8c9edd741e34f87559e53472c104504ab16e81 (wtxid=76e95ac81ad1ba5151687d4bb4309721746271284a4c563c79a201b2c90f0019) with 34debb7e99e0539d3671105aae44a6b06ae0b0b56907deb3232caa45ec75efc1 (wtxid=c85cf5b3cb64328dc455d8b2e62ba61ff48a34b7e3059128ef04b95b64b58683) for -0.00009301 additional fees, -481 delta bytes
> 2024-02-10T01:48:15Z [mempool] replacing tx a7258a7a5cef585f75bb9d67eb6f8a2bd832bb42e7a4cf962c37ea8c1a3ca3dd (wtxid=b3ab131da10e8de47459c4920aff4bc6cc5beb34249c41cdeb96b785d9632fac) with 34debb7e99e0539d3671105aae44a6b06ae0b0b56907deb3232caa45ec75efc1 (wtxid=c85cf5b3cb64328dc455d8b2e62ba61ff48a34b7e3059128ef04b95b64b58683) for -0.00009301 additional fees, -481 delta bytes
> 2024-02-10T01:48:15Z [mempool] replacing tx 624e6a56f8bd9acaf594a180d77fa2dad21ec0164f6496b1875af600e3d64cf2 (wtxid=26afba898925788e23781d509dd3918fca8b2cdeaf6ff06a65640cb639b5a1bd) with 34debb7e99e0539d3671105aae44a6b06ae0b0b56907deb3232caa45ec75efc1 (wtxid=c85cf5b3cb64328dc455d8b2e62ba61ff48a34b7e3059128ef04b95b64b58683) for -0.00009301 additional fees, -481 delta bytes
>
> outcome: lost
>
>
>
> 2024-01-24T02:12:47Z [mempool] replacing tx 639ab332c1c257b04cffd3410199cb0af547e8ea9f7eeb29f9d0b4b24801680c (wtxid=639ab332c1c257b04cffd3410199cb0af547e8ea9f7eeb29f9d0b4b24801680c) with 281405690ccf1e6b3e18b37856fa60d5a66d7aae47577776ed8dcef73ce5d6c7 (wtxid=281405690ccf1e6b3e18b37856fa60d5a66d7aae47577776ed8dcef73ce5d6c7) for -0.00009195 additional fees, -976 delta bytes
>
> outcome: 281405690ccf1e6b3e18b37856fa60d5a66d7aae47577776ed8dcef73ce5d6c7 won, mined by f2pool; replaced tx ~4 hours old
>
>
> 2024-01-23T22:57:15Z [mempool] replacing tx 54a33daa3eb300f2ea7261d6f4fdd026424aad3a9e65383b97576d70c59ff625 (wtxid=54a33daa3eb300f2ea7261d6f4fdd026424aad3a9e65383b97576d70c59ff625) with 867f9bf7e1aaec55f2a6552cb6e31ccce7c0aa75f9a08ae84c23960fc5951247 (wtxid=867f9bf7e1aaec55f2a6552cb6e31ccce7c0aa75f9a08ae84c23960fc5951247) for -0.00008978 additional fees, -326 delta bytes
> 2024-01-23T22:57:15Z [mempool] replacing tx 2cee5a3753ea4906677a749300ff95d00d4dfd9c1c49fb8ea42b6919e5b8075b (wtxid=e73f5cfaf6a6c5ec6fa68edcf2c741a2c9306bf85e1f2ed6d7424757aa0ceeff) with 867f9bf7e1aaec55f2a6552cb6e31ccce7c0aa75f9a08ae84c23960fc5951247 (wtxid=867f9bf7e1aaec55f2a6552cb6e31ccce7c0aa75f9a08ae84c23960fc5951247) for -0.00008978 additional fees, -326 delta bytes
>
> outcome: lost
>
>
> 2024-02-08T02:53:17Z [mempool] replacing tx fdf726e40c61c9e78a4cbefcc38a9683b4a270020109ccc6584275d05dcffe88 (wtxid=793d89e1d27b1b001d485c277f2228a96674c6d15d21b012e84cffd89bb2f919) with 14b25c18e9ed920fac5e824ac92dc459f61abf89ea5a2c887b48bac4db4d5642 (wtxid=f8aac96aebdd5f4ed1094fae09bfe5be062e3e14f3907a94cc2573067137d764) for -0.00005916 additional fees, -180 delta bytes
> 2024-02-08T02:53:17Z [mempool] replacing tx 700179e09161b178f4346c296d28d1273a5b487a10e1dad6c90a763736fc40b6 (wtxid=b39281d543eacd32187b5b9b226dddfccdf33c6d979bfd8d58b73d5168d60968) with 14b25c18e9ed920fac5e824ac92dc459f61abf89ea5a2c887b48bac4db4d5642 (wtxid=f8aac96aebdd5f4ed1094fae09bfe5be062e3e14f3907a94cc2573067137d764) for -0.00005916 additional fees, -180 delta bytes
>
> outcome: unclear, as fdf72 never got mined and don't have logs as to what it actually was
>
>
> 2024-02-14T08:33:03Z [mempool] replacing tx e16b43bfc2fb510ed2d7e5e4e89f94790f5f44ef6c643efe5eab1b12a30f016f (wtxid=7536fbdcfcfe3381be4f6bffed2ef68228615c1b29080029389cf6b29e0a4bd1) with 71b0c8ca444b60bfb16a19bad8b399c2b5e9722865e00e713d47c65cf77728a3 (wtxid=d9f8dec57ff3905694691ea871897fa7e2011a6a7a95132a63fb4166942895b9) for -0.0000588 additional fees, -168 delta bytes
> 2024-02-14T08:33:03Z [mempool] replacing tx b309997ea34321a16649bdb0998b1e6252aa48ed5f293ae1c251db6cd32dd9a5 (wtxid=b18d3e91956ddb7e78590aad4e3bdb25f5ec44e912ff96bacd5426c71f2b3f3d) with 71b0c8ca444b60bfb16a19bad8b399c2b5e9722865e00e713d47c65cf77728a3 (wtxid=d9f8dec57ff3905694691ea871897fa7e2011a6a7a95132a63fb4166942895b9) for -0.0000588 additional fees, -168 delta bytes
>
> outcome: lost
>
>
> 2024-01-24T12:51:40Z [mempool] replacing tx 622d04cfa4b0c2da7ff52d787369139f14dfb7374ce8361636eeaf1ede0d1795 (wtxid=8107c0f45175d1cc07bf0fbf12ccd05bce2bd01adf9a75ff6fb20023fdb2b565) with 5c611198a41cb9f8ec9a44c3d66752312524dc265ee9ccbacf338dd14b202f8c (wtxid=b0567ae9a84f4467a6fe70f84de4dc89b9aec1aca156419b1463149055e7b27b) for -0.00005218 additional fees, -402 delta bytes
> 2024-01-24T12:51:40Z [mempool] replacing tx ded2f2189c2d6292104457d4d8006bb0e6f06b5be7c63fa3893bcd83059313a3 (wtxid=f43098191c4674c480ef2a278015561101043b815be484feb776b9e2a1cac9ed) with 5c611198a41cb9f8ec9a44c3d66752312524dc265ee9ccbacf338dd14b202f8c (wtxid=b0567ae9a84f4467a6fe70f84de4dc89b9aec1aca156419b1463149055e7b27b) for -0.00005218 additional fees, -402 delta bytes
> 2024-01-24T12:51:40Z [mempool] replacing tx ee09c7533f59ee69dc8bea7f1b63ea9b10ede7de3c2fb2ee0870b6160cac74ab (wtxid=30575e5c7d64222687febebd47124bbc25ec06ae90ebaf679ed120684fe73075) with 5c611198a41cb9f8ec9a44c3d66752312524dc265ee9ccbacf338dd14b202f8c (wtxid=b0567ae9a84f4467a6fe70f84de4dc89b9aec1aca156419b1463149055e7b27b) for -0.00005218 additional fees, -402 delta bytes
> 2024-01-24T12:51:40Z [mempool] replacing tx 04c4dd8ac5c9356e34aed870e9b221da2e358c904e6c8abecb1edc63b6808fdd (wtxid=e4f39d7cd0614b7e85b33e213989aed3376d4b78787081c2e6a3c32fb20bb5b8) with 5c611198a41cb9f8ec9a44c3d66752312524dc265ee9ccbacf338dd14b202f8c (wtxid=b0567ae9a84f4467a6fe70f84de4dc89b9aec1aca156419b1463149055e7b27b) for -0.00005218 additional fees, -402 delta bytes
>
> outcome: 5c611198a41cb9f8ec9a44c3d66752312524dc265ee9ccbacf338dd14b202f8c won, mined by mara pool; unclear how old replaced txs were
>
>
> 2024-02-09T22:09:44Z [mempool] replacing tx ec5e68cc99d1184a5e01c92a01cee43104e09934eacb9489bd71039240b2409f (wtxid=0c179ced549a2ce013ecf75e210d6de43c5331d6c06c1593a2d7619216e2f6ae) with 1d25f2be63cad67c68528bfdcdf248fda1909dd7bef71f27a5fe9056ff9368b7 (wtxid=2d6e55531676b7b3b0dba67a9367f3f25536463c3e96c59b1c0b67945c4d90bc) for -0.00003893 additional fees, -1133 delta bytes
>
> outcome: 1d25f2be63cad67c68528bfdcdf248fda1909dd7bef71f27a5fe9056ff9368b7 won, mined by f2pool; replaced tx was ~35 hours old
>
>
> 2024-02-15T15:00:13Z [mempool] replacing tx 4d4deb6e9170486724cdb0df8a1e4a1869d8b09c3e734a4781488a37417df8be (wtxid=4b65734a764b80cd80dccd26180ec7cba7463e66f347969c3b9ff450be8adfd7) with bbb06e7bd26e3010c9c0c8907850ac27aa7d842f8a888d757e41e1cf7c4f8cc0 (wtxid=88410651f659d234115180c959af0c958fb19e427cddd2b57c670c40fa37b59a) for -0.00003468 additional fees, -1487 delta bytes
> 2024-02-15T15:00:13Z [mempool] replacing tx 21696be674c6b02d013baf58f7f8f2bde8db6de17a8bc413714b69e3f2f9a0c8 (wtxid=b5d3e6f97bd695450fcb00731e69b2c4cf671508e17f5068cc4ee28e8d3edb42) with bbb06e7bd26e3010c9c0c8907850ac27aa7d842f8a888d757e41e1cf7c4f8cc0 (wtxid=88410651f659d234115180c959af0c958fb19e427cddd2b57c670c40fa37b59a) for -0.00003468 additional fees, -1487 delta bytes
>
> outcome: bbb06e7bd26e3010c9c0c8907850ac27aa7d842f8a888d757e41e1cf7c4f8cc0 won, mined by f2pool; replaced txs were multiple days old
>
>
> 2024-02-04T16:11:10Z [mempool] replacing tx bfe8dbd86485710e0d562b8b4df58583aeb96f26beb180668f113127acffb3fb (wtxid=bac1485cc7cc99e46525c258fe682284e2ae9a9a650ea547a83719cab9cbc8c0) with 6cc0ea35c16a99828071d0ace21726c889cc920c6e4986b58c2e08ed0024787e (wtxid=51d23c0488460dd3e3db887c13a724eefdd2e0660d7abaf5ab598fe2334ddb15) for -0.00002919 additional fees, -360 delta bytes
>
> outcome: 6cc0ea35c16a99828071d0ace21726c889cc920c6e4986b58c2e08ed0024787e won, mined by mara pool; replaced tx was ~13 hours old
>
>
> 2024-02-21T12:36:46Z [mempool] replacing tx 2a73fdfdb16a71f55ad6fb0e3165029c51b6b9247fdb88e0e44ad2bb432f8612 (wtxid=3fb092bf764450f3c90cc8856a578283a6586ecda5271004df0db4e65faab0a1) with 1a188e2d321f2b4a544a46843f9c0ce16bdd2cb40b560815297bfab506f53aa5 (wtxid=589dbfe1f80a569bd9253e61b88dfb8ea5e9305698a060bf68633852c75e596f) for -0.0000167 additional fees, -208 delta bytes
> 2024-02-21T12:36:46Z [mempool] replacing tx ace0e82d9b3df4a4571d2b764223626536fb4a21bb19eff110cbe235cacb8062 (wtxid=8f45a033255c246ecf67bef065ba9be1d4c38295aa0a2849f641c69b13123bfc) with 1a188e2d321f2b4a544a46843f9c0ce16bdd2cb40b560815297bfab506f53aa5 (wtxid=589dbfe1f80a569bd9253e61b88dfb8ea5e9305698a060bf68633852c75e596f) for -0.0000167 additional fees, -208 delta bytes
>
> outcome: 1a188e2d321f2b4a544a46843f9c0ce16bdd2cb40b560815297bfab506f53aa5 won, mined by antpool; replaced txs only a few minutes old
>
>
> 2024-01-25T00:52:59Z [mempool] replacing tx 3bdd7b3c76cde41c0d8602a4d21c277350bc2f111f1ce1e543b6b49957c43244 (wtxid=3bdd7b3c76cde41c0d8602a4d21c277350bc2f111f1ce1e543b6b49957c43244) with d38eaf2d7a0a4443703a1f52804aadf2ded6c92bcd010ece323b7dea66427910 (wtxid=d38eaf2d7a0a4443703a1f52804aadf2ded6c92bcd010ece323b7dea66427910) for -0.00001142 additional fees, -191 delta bytes
> 2024-01-25T00:52:59Z [mempool] replacing tx 24c977c2306a56bb29734e97f1d5c674e324b090a108a267cd9a91ef84d8d671 (wtxid=24c977c2306a56bb29734e97f1d5c674e324b090a108a267cd9a91ef84d8d671) with d38eaf2d7a0a4443703a1f52804aadf2ded6c92bcd010ece323b7dea66427910 (wtxid=d38eaf2d7a0a4443703a1f52804aadf2ded6c92bcd010ece323b7dea66427910) for -0.00001142 additional fees, -191 delta bytes
>
> outcome: d38eaf2d7a0a4443703a1f52804aadf2ded6c92bcd010ece323b7dea66427910 won, mined by mara pool; replaced txs ~20 minutes old
>
>
> 2024-02-20T01:11:00Z [mempool] replacing tx 2d58982eacae6acdebc719018de62669a8d47bdac068e8f48316406ab1ac4b03 (wtxid=f99e1001786a067d48045dc7abc7f3bc2cb98e9578f3dc1bb90fc93a004d6b47) with 9f5e001faf92b801eb626587f68986bf2ff1a8c3eddaa0d471d28bcdabe4af54 (wtxid=ab043f343c704f90af12a252b98cdf15c0e7adb2eb07abe9b8579ba13e4d3353) for -0.00000198 additional fees, -349 delta bytes
> 2024-02-20T01:11:00Z [mempool] replacing tx 300e937ea3617a99d1a9f0bcbdb7b51ad8785015e343e40822071653d913da2c (wtxid=253af0c23392ba028a8af719bdada8dc4aab0bcd6c4dd7b146a4b0717fd83d1c) with 9f5e001faf92b801eb626587f68986bf2ff1a8c3eddaa0d471d28bcdabe4af54 (wtxid=ab043f343c704f90af12a252b98cdf15c0e7adb2eb07abe9b8579ba13e4d3353) for -0.00000198 additional fees, -349 delta bytes
> 2024-02-20T01:11:00Z [mempool] replacing tx f758901698069d7649e02b50d7f96b6ade7f4d782a17fc7a5d0b4f95c7f595ea (wtxid=9a9f7d5398f9f56d113448cab25dfd17714727fc4f912b3a72f36d4ef005b1d6) with 9f5e001faf92b801eb626587f68986bf2ff1a8c3eddaa0d471d28bcdabe4af54 (wtxid=ab043f343c704f90af12a252b98cdf15c0e7adb2eb07abe9b8579ba13e4d3353) for -0.00000198 additional fees, -349 delta bytes
>
> outcome: 9f5e001faf92b801eb626587f68986bf2ff1a8c3eddaa0d471d28bcdabe4af54 won, mined by sbi crypto; replaced txs were many hours old
>
> total: 14
> unclear: 2
> lost: 3
> rbfr mined: 9
>
> total rbfr mined: 64%
> ```
>
> --
> https://petertodd.org 'peter'[:-1]@petertodd.org
>
> --
> 


 permalink raw reply	[|nested]
2024-02-24 17:55 ` Nagaev Boris

  2024-02-24 20:54     ` Nagaev Boris
  
From: Peter Todd @ 2024-02-24 18:45 UTC (permalink / raw)
  To: Nagaev Boris;  bitcoindev

[-- Attachment #1: Type: text/plain, Size: 2259 bytes --]

On Sat, Feb 24, 2024 at 02:55:26PM -0300, Nagaev Boris wrote:
> > I recently released a [prototype Libre Relay fork](https://github.com/petertodd/bitcoin/tree/libre-relay-v26.0) of Bitcoin Core v26.0, that among
> > other things, implements [Pure Replace-By-Fee-Rate](/2024/one-shot-replace-by-fee-rate#pure-replace-by-fee-rate) (RBFR)
> > with a 2x ratio. This means that transactions will be replaced if the fee-rate
> > of the new transaction is at least 2x higher than the old transaction(s), even
> > if the absolute fee is lower.
> 
> I like the idea of pure replacement by fee rate, but I'm not sure
> about the 2x coefficient. I'm afraid it can result in overpaying.
> 
> What is the purpose of the 2x coefficient? Is it needed to prevent DoS
> by continuously increasing feerate by a fraction of a percent? Isn't
> 1.1x enough to prevent this DoS vector? A rise from 100 sats/byte to
> 110 sats/byte is easier to bear, then a rise from 100 to 200,
> especially if the next block feerate is 105.

The coefficient is a trade-off between overpaying and DoS attack cost. The
smaller the coefficient, the more replacements that can be done:

2^10    = 1024
1.5^10  = 58
1.25^10 = 9.3
1.1^10  = 2.6

I picked 2x for the prototype because it's:

1) A safe default that makes DoS attacks _very_ expensive.
2) Low enough that the primary purpose of preventing pinning attacks still
   works.
3) High enough to be clearly incentive compatible for miners.
4) A ratio that's easy to implement with addition.

The last reason is kinda funny... CFeeRate in Bitcoin Core v26.0 doesn't
support multiplication or division operations. So I implemented the 2x ratio by
just adding a fee-rate to itself.

Personally, I think 1.25 would be a reasonable ratio. But I wanted to release a
conservative version first to minimize the impact of DoS attacks.

-- 
https://petertodd.org 'peter'[:-1]@petertodd.org

-- 
asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

 permalink raw reply	[|nested]
2024-02-24 18:45   ` Peter Todd

  2024-02-24 22:25       ` Peter Todd
  
From: Nagaev Boris @ 2024-02-24 20:54 UTC (permalink / raw)
  To: Peter Todd;  bitcoindev

On Sat, Feb 24, 2024 at 3:45 PM Peter Todd <pete@petertodd•org> wrote:
>
> On Sat, Feb 24, 2024 at 02:55:26PM -0300, Nagaev Boris wrote:
> > > I recently released a [prototype Libre Relay fork](https://github.com/petertodd/bitcoin/tree/libre-relay-v26.0) of Bitcoin Core v26.0, that among
> > > other things, implements [Pure Replace-By-Fee-Rate](/2024/one-shot-replace-by-fee-rate#pure-replace-by-fee-rate) (RBFR)
> > > with a 2x ratio. This means that transactions will be replaced if the fee-rate
> > > of the new transaction is at least 2x higher than the old transaction(s), even
> > > if the absolute fee is lower.
> >
> > I like the idea of pure replacement by fee rate, but I'm not sure
> > about the 2x coefficient. I'm afraid it can result in overpaying.
> >
> > What is the purpose of the 2x coefficient? Is it needed to prevent DoS
> > by continuously increasing feerate by a fraction of a percent? Isn't
> > 1.1x enough to prevent this DoS vector? A rise from 100 sats/byte to
> > 110 sats/byte is easier to bear, then a rise from 100 to 200,
> > especially if the next block feerate is 105.
>
> The coefficient is a trade-off between overpaying and DoS attack cost. The
> smaller the coefficient, the more replacements that can be done:
>
> 2^10    = 1024
> 1.5^10  = 58
> 1.25^10 = 9.3
> 1.1^10  = 2.6

Very interesting!

To assess the number of DoS replacements, given RBFR is implemented
with coefficient K, we need to know the following two numbers,
available on mempool.space front page:

 - Purging feerate (P)
 - Next block feerate (N)

For an attacker, to cause the most number of replacements, it is
rational to first introduce a tx with fee rate just above purging
feerate and then increase its feerate by K times until it reaches next
block feerate (N).

So the number of replacements he can successfully cause paying price N
per byte is:

floor(log(K, N/P))

Currently N=11, P=1.13 (satoshis/byte).
For K=2 the number of replacements is 3.
For K=1.25 it is 10.
For K=1.1 it is 23.

It would be valuable to get access to archival values of Purging
feerate and Next block feerate. Knowing max(N/P) over the whole time
is needed to know the exact number of replacements for an attack in
the worst case in the past.

The strength of a DoS attack is proportional to 1/log(K).
So the price of a DoS attack is proportional to log(K).
The price of RBFR for a legitimate user is proportional to K - 1 - N /
R, where N is the Next block feerate at RBF time and R is the feerate
at which the tx was previously broadcasted (originally or previous
RBF).

Another piece of data which would be very valuable are N and R for
historical RBF events. If K is set to median N / R, then RBFR would
cost nothing to the average legitimate user and cost something to an
attacker, which is a good thing.


> I picked 2x for the prototype because it's:
>
> 1) A safe default that makes DoS attacks _very_ expensive.
> 2) Low enough that the primary purpose of preventing pinning attacks still
>    works.
> 3) High enough to be clearly incentive compatible for miners.
> 4) A ratio that's easy to implement with addition.
>
> The last reason is kinda funny... CFeeRate in Bitcoin Core v26.0 doesn't
> support multiplication or division operations. So I implemented the 2x ratio by
> just adding a fee-rate to itself.

Yeah, it is funny :-)

By the way, K=1.25 is also easy to implement using just additions:

bool enough_increase(CFeeRate oldrate, newrate) {
  auto oldx2 = oldrate + oldrate;
  auto oldx5 = oldx2 + oldx2 + oldrate;
  auto newx2 = newrate + newrate;
  auto newx4 = newx2 + newx2;
  return newx4 >= oldx5;
}

Also CFeeRate supports integer multiplication, so it can be simplified as:

bool enough_increase(CFeeRate oldrate, newrate) {
  return (4 * newrate) >= (5 * oldrate);
}

> Personally, I think 1.25 would be a reasonable ratio. But I wanted to release a
> conservative version first to minimize the impact of DoS attacks.
>
> --
> https://petertodd.org 'peter'[:-1]@petertodd.org



-- 
Best regards,
Boris Nagaev

-- 



 permalink raw reply	[|nested]
2024-02-24 20:54     ` Nagaev Boris

  
From: Peter Todd @ 2024-02-24 22:25 UTC ( / )
  To: Nagaev Boris;  bitcoindev



On Sat, Feb 24, 2024 at 05:54:52PM -0300, Nagaev Boris wrote:
> > The coefficient is a trade-off between overpaying and DoS attack cost. The
> > smaller the coefficient, the more replacements that can be done:
> >
> > 2^10    = 1024
> > 1.5^10  = 58
> > 1.25^10 = 9.3
> > 1.1^10  = 2.6
> 
> Very interesting!
> 
> To assess the number of DoS replacements, given RBFR is implemented
> with coefficient K, we need to know the following two numbers,
> available on mempool.space front page:
> 
>  - Purging feerate (P)
>  - Next block feerate (N)
> 
> For an attacker, to cause the most number of replacements, it is
> rational to first introduce a tx with fee rate just above purging
> feerate and then increase its feerate by K times until it reaches next
> block feerate (N).

Note that next block feerate isn't actually the limit in the Libre Relay
implementation. It's memoryless, and does not depend on overall mempool
conditions, so you can continue to RBFR replace even beyond the next block
feerate.

Of course, if you do that you're spending a heck of a lot of money that could
be used on a cheaper attack.

> Another piece of data which would be very valuable are N and R for
> historical RBF events. If K is set to median N / R, then RBFR would
> cost nothing to the average legitimate user and cost something to an
> attacker, which is a good thing.

Absolute maximum next block fee rate historically has been <1000sat/vB;
absolute minimum has been 1sat/vB. Just using those numbers for sake of
conservativism is probably fine:

1.25^32 ~= 1010
1.15^50 ~= 1084

After all, you're putting up a *lot* of money for the privilege of using
relatively little bandwidth at anything but relatively small fee-rates. As per
my prior analysis of this topic, it's probably cheaper to just DoS attack
public nodes directly, with similarish effectiveness:

https://petertodd.org/2024/one-shot-replace-by-fee-rate#denial-of-service-attacks

> > I picked 2x for the prototype because it's:
> >
> > 1) A safe default that makes DoS attacks _very_ expensive.
> > 2) Low enough that the primary purpose of preventing pinning attacks still
> >    works.
> > 3) High enough to be clearly incentive compatible for miners.
> > 4) A ratio that's easy to implement with addition.
> >
> > The last reason is kinda funny... CFeeRate in Bitcoin Core v26.0 doesn't
> > support multiplication or division operations. So I implemented the 2x ratio by
> > just adding a fee-rate to itself.
> 
> Yeah, it is funny :-)
> 
> By the way, K=1.25 is also easy to implement using just additions:
> 
> bool enough_increase(CFeeRate oldrate, newrate) {
>   auto oldx2 = oldrate + oldrate;
>   auto oldx5 = oldx2 + oldx2 + oldrate;
>   auto newx2 = newrate + newrate;
>   auto newx4 = newx2 + newx2;
>   return newx4 >= oldx5;
> }

lololol

> Also CFeeRate supports integer multiplication, so it can be simplified as:
> 
> bool enough_increase(CFeeRate oldrate, newrate) {
>   return (4 * newrate) >= (5 * oldrate);
> }

Check git blame: that's actually new! The v26.0 code base doesn't have that
patch. Not sure if v26.1 will have it either. Of course, easy to just
cherry-pick it at this point.

-- 
https://petertodd.org 'peter'[:-1]@petertodd.org

--