nSequence-based Full-RBF opt-in #6871

pull petertodd wants to merge 9 commits into bitcoin:master from petertodd:2015-10-rbf-with-opt-out changing 7 files +1089 −9
  1. petertodd commented at 10:11 pm on October 22, 2015: contributor

    Replaces transactions already in the mempool if a new transaction seen with a higher fee, specifically both a higher fee per KB and a higher absolute fee. Children are evaluated for replacement as well, using the mempool package tracking to calculate replaced fees/size efficiently. Transactions opt-in to transaction replacement by setting nSequence < maxint-1 on at least one input. (which no wallet currently does)

    No first-seen-safe functionality, but that can easily be added as a separate pull if there’s demand from wallet vendors.

    If anyone feels like converting the tests to the internal python library used by the qa/rpc-tests, pull-reqs accepted.

  2. gmaxwell commented at 10:13 pm on October 22, 2015: contributor
    Feedback I heard from wallet vendors previously was that FSS was burdensome (needed extra txins, and so less useful).
  3. petertodd commented at 10:16 pm on October 22, 2015: contributor
    @gmaxwell Same feedback I’ve heard too.
  4. TheBlueMatt commented at 10:37 pm on October 22, 2015: member
    Concept ACK.
  5. btcdrak commented at 10:48 pm on October 22, 2015: contributor
    Concept ACK.
  6. dcousens commented at 10:50 pm on October 22, 2015: contributor
    concept ACK
  7. dcousens commented at 10:50 pm on October 22, 2015: contributor
    How does this work with CPFP, and descendent transactions (e.g a chained transaction that could have its based replaced?)
  8. petertodd commented at 10:59 pm on October 22, 2015: contributor

    @dcousens What do you mean “how does this work” with CPFP? CPFP isn’t implemented in Bitcoin Core, so there’s nothing to affect.

    Now, when replacing a tx with children, the fees and size of all children are taken into account before deciding to replace or not.

  9. dcousens commented at 11:02 pm on October 22, 2015: contributor

    @dcousens What do you mean “how does this work” with CPFP? CPFP isn’t implemented in Bitcoin Core, so there’s nothing to affect.

    I meant conceptually, sorry. CPFP is something that was on the roadmap AFAIK?

    all children are taken into account before deciding to replace or not.

    By taken into account, do you mean that you have to have a higher fee than all subsequent children to replace?

  10. petertodd commented at 11:05 pm on October 22, 2015: contributor

    By taken into account, do you mean that you have to have a higher fee than all subsequent children?

    Yes.

    Only extremely sophisticated CPFP that does relaying of whole packages of transactions based on fees paid by children is affected by RBF, and no-one has any plans to actually implement that yet.

  11. petertodd force-pushed on Oct 22, 2015
  12. petertodd renamed this:
    Full-RBF with opt-out
    nSequence-based Full-RBF opt-in
    on Oct 23, 2015
  13. greenaddress commented at 6:51 am on October 23, 2015: contributor
    Concept ACK
  14. rubensayshi commented at 9:24 am on October 23, 2015: contributor
    concept ACK
  15. laanwj added the label Mempool on Oct 23, 2015
  16. jtimon commented at 11:28 am on October 23, 2015: contributor
    Concept ACK
  17. in src/main.cpp: in b233451b00 outdated
    1025+
    1026+            // Finally replace only if we end up with a larger fees-per-kb than
    1027+            // the replacements.
    1028+            CFeeRate oldFeeRate(nConflictingFees, nConflictingSize);
    1029+            CFeeRate newFeeRate(nFees, nSize);
    1030+            if (newFeeRate <= oldFeeRate)
    


    sdaftuar commented at 8:55 pm on October 23, 2015:
    I’m not sure this comparison makes sense. The existence of a low-fee-rate descendant doesn’t make a transaction worse for miners, but it would cause the feerate to look worse in this comparison.

    petertodd commented at 11:03 pm on October 23, 2015:

    So, you mean the scenario where we have a high fee-rate transaction that is spent by one or more low fee-rate transactions? For instance suppose we have two transactions in our mempool: tx1a, 1KB w/ 1mBTC fee, which is spent by tx2, 10KB w/ 1mBTC fee. We get tx1b, 10KB w/ 2.1mBTC fee. Since the overall feerate of tx1b is higher than tx1a+tx2, it’ll be accepted, even though a miner might have rather mined tx1a instead, ignoring tx2 (for now).

    I agree that’s less than optimal. If we make the assumption that there’s always more demand for blockchain space than supply, it might be reasonable for the replacement logic criteria to be whether or not we’re increasing the fee-rate of any subset of the mempool. (while still paying more fees than the replaced transactions)

    Without taking CPFP into account, you could simply use the same kind of priority heap logic as in CreateNewBlock() on the list of transactions that would be replaced by the new transaction. You’d iterate through the heap from highest priority to lowest, stopping once you had found as many bytes worth of transactions as the candidate replacement. If the fee-rate of the replacement is higher than the fee-rate of those transactions, accept the replacement into the mempool.

    To take CPFP into account… Thinking about it more the mempool package tracking is probably backwards from what we want. Right now it tracks descendants, when really what we want to know is “what’s the total fee-rate if I mine this transaction, and all ancestors?” If we kept track of “packages” that way, we’d be able to do the comparison by determining if the total fee-rate of the new package created by the replacement is higher than the fee-rates of all the packages invalidated by it. I actually did some work on something along these lines a few years ago, though didn’t finish it - the implementation is a lot simpler now that we have strict ancestor limits. (when limiting, just throw away the tx associated with the lowest fee-rate package, which is guaranteed to have no descendants)

    For now though I’d be inclined to merge this PR as-is, as all the above options are pretty complex. I also don’t see any way this code could be used in an DoS attack.


    sdaftuar commented at 6:18 pm on October 26, 2015:

    Right, the distinction between ancestor and descendant package is what I was getting at.

    Descendant packages are I think the right thing to use for mempool limiting. I don’t follow what you’re saying about a limiting algorithm that uses fee with ancestors – it’s entirely possible that the worst thing under that sort would have descendants in the mempool.

    (FYI I have a branch that implements ancestor packages. I might propose merging it at some point if it looks like we can take advantage of it in the mining code, but I’m not ready to advocate that now.)

    Anyway in this code, we are comparing the feerate of the replacing transaction (with uncalculated/unknown fee rate including its ancestors) to an estimate of the feerate of the descendants of all the conflicting transactions. This strikes me as incorrect on both fronts; by not putting any bounds on the ancestor fee rate, we might be accepting a replacement transaction that is unlikely to confirm anytime soon. On the other hand, by looking at feerate with children (and overcounting those children, at least in the current implementation), we might be making it so that miners would prefer the original transactions to the replacing one.

    I don’t know that either of these issues constitutes an attack, but I do think it’s useful to try to help users avoid shooting themselves in the foot, say by accidentally adding an input that is part of a long unconfirmed chain (causing the replacing transaction to be worse), and to give miners code that doesn’t require further optimization to do the economically rational thing.

    So with that in mind, how about this:

    • Require that any new inputs that show up in the replacing transaction be already confirmed. In the future, if we do merge something like ancestor package tracking and better mining code, we could update this test appropriately.
    • Require that for each entry E in setConflicts, feerate(replacing transaction) > max(feerate of E, feerate of E with descendants). That doesn’t completely eliminate the possibility that it could be somehow worse for a miner to accept the new transaction, but it eliminates some degenerate cases (where a high fee rate transaction is dragged down by lower fee rate transactions) and is easy to calculate.

    petertodd commented at 4:07 am on October 30, 2015:

    Fixed both these issues.

    I decided not to do the max() version of this, as I think the requirement that the new fees > total-replaced-fees is sufficient; might help to get txs unstuck in some cases, and non-CPFP miners aren’t evaluating that anyway.

  18. instagibbs commented at 1:17 pm on October 26, 2015: member
    Concept ACK. FSS is a pain.
  19. in qa/replace-by-fee/rbf-tests.py: in b233451b00 outdated
    37+    @classmethod
    38+    def tearDownClass(cls):
    39+        # Make sure mining works
    40+        mempool_size = 1
    41+        while mempool_size:
    42+            cls.proxy.generate(1)
    


    sdaftuar commented at 5:25 pm on October 26, 2015:

    When I check out the commit referenced in the README and run the test, I get an error: AttributeError: 'Proxy' object has no attribute 'generate'

    I think this function is not defined in the Proxy class? Adding it in the appropriate place in python-bitcoinlib seems to fix it.


    instagibbs commented at 5:30 pm on October 26, 2015:

    It’s not included, no. You can just do a “call” instead.

    proxy.call(“generate”, 1)


    petertodd commented at 1:51 am on October 30, 2015:

    Fixed.

    I forgot to add generate() when python-bitcoinlib dropped support for calling RPC commands implicitly; replaced with .call() so as to continue to use the official v0.5.0 release rather than git master.

  20. in src/main.cpp: in b233451b00 outdated
    805@@ -806,15 +806,42 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa
    806         return state.Invalid(false, REJECT_ALREADY_KNOWN, "txn-already-in-mempool");
    807 
    808     // Check for conflicts with in-memory transactions
    809+    set<uint256> setConflicts;
    810     {
    811     LOCK(pool.cs); // protect pool.mapNextTx
    812-    for (unsigned int i = 0; i < tx.vin.size(); i++)
    813+    BOOST_FOREACH(const CTxIn txin, tx.vin)
    


    sdaftuar commented at 5:25 pm on October 26, 2015:
    Any reason not to make this const CTxIn &txin, here and at line 832 below?

    petertodd commented at 1:53 am on October 30, 2015:
    Good point! Fixed.
  21. in src/main.cpp: in b233451b00 outdated
    963+        // that we have the set of all ancestors we can detect this
    964+        // pathological case by making sure setConflicts and setAncestors don't
    965+        // intersect.
    966+        BOOST_FOREACH(CTxMemPool::txiter ancestorIt, setAncestors)
    967+        {
    968+            const uint256 hashAncestor = ancestorIt->GetTx().GetHash();
    


    sdaftuar commented at 5:26 pm on October 26, 2015:
    This could also be const uint256 &hashAncestor.

    petertodd commented at 1:54 am on October 30, 2015:
    Also fixed.
  22. in src/main.cpp: in b233451b00 outdated
    986+            // Check if it's economically rational to mine this transaction
    987+            // rather than the ones it replaces. For efficiency we simply sum
    988+            // up the pre-calculated fees/size-with-descendants values from the
    989+            // mempool package tracking; this does mean the pathological case
    990+            // of diamond tx graphs will be overcounted.
    991+            BOOST_FOREACH(const uint256 hashConflicting, setConflicts)
    


    sdaftuar commented at 5:34 pm on October 26, 2015:

    I think this logic needlessly overcounts the descendants. Why not just call CalculateDescendants on the entries in setConflicts, and then loop over all of them?

    Assuming the replacing transaction is successful, you don’t end up wasting any time, because you can pass the descendant set directly into RemoveStaged later.

    If the replacing transaction were to fail, and we’re worried about the amount of work an attacker might try to make us do, then we could just put a work bound here where we fail to replace if there are too many things to look at.

    I think it’s a good idea to address though because a simple pattern where you have two parent transactions that are spent by a single child of both couldn’t be consolidated down to a single transaction without paying for that child twice, if we went with this algorithm; that seems like a needless overhead.


    petertodd commented at 2:00 am on October 30, 2015:

    Well, I’m trying to keep this pull as simple as possible, while writing it in a way that isn’t likely to lead to any DoS attacks; a previous version of this patch did do exactly what you suggest, but given that descendant tracking exists I figured I’d use it. (after all, I’m writing this patch pro bono)

    As for your example where it would matter, that’d require wallets that attempted to both get txs to non-RBF miners and RBF miners simultaneously by broadcasting one then the other. It’s a good idea, but doing that doesn’t yet save you any money due to the rule that replacements must pay >= the fees of the transactions being replaced.

  23. in src/main.cpp: in b233451b00 outdated
    827+                // maxint-1 is picked to still allow use of nLockTime by
    828+                // non-replacable transactions. All inputs rather than just one
    829+                // is for the sake of multi-party protocols, where we don't
    830+                // want a single party to be able to disable replacement.
    831+                //
    832+                // The opt-out ignores decendents as anyone relying on
    


    sdaftuar commented at 5:40 pm on October 26, 2015:
    nit: “descendants”

    petertodd commented at 2:01 am on October 30, 2015:
    Fixed
  24. in src/main.cpp: in b233451b00 outdated
    1057@@ -952,6 +1058,19 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa
    1058                 __func__, hash.ToString(), FormatStateMessage(state));
    1059         }
    1060 
    1061+        // Remove conflicting transactions from the mempool
    1062+        list<CTransaction> ltxConflicted;
    1063+        pool.removeConflicts(tx, ltxConflicted);
    1064+
    1065+        BOOST_FOREACH(const CTransaction &txConflicted, ltxConflicted)
    


    sdaftuar commented at 6:28 pm on October 26, 2015:
    Just to add on to my comment above – if you call CalculateDescendants above and use RemoveStaged here, then we don’t have to copy all these transactions…

    petertodd commented at 2:02 am on October 30, 2015:
    Agreed. Although again, I’m not worried about the case where the transactions do end up replaced; I’m worried about the possible DoS attack case where they aren’t.
  25. petertodd commented at 6:52 pm on November 4, 2015: contributor
  26. dcousens commented at 0:36 am on November 5, 2015: contributor
    Great work @sdaftuar on the added tests, once-over ACK
  27. btcdrak commented at 5:19 pm on November 5, 2015: contributor
    needs rebase
  28. gmaxwell added this to the milestone 0.12.0 on Nov 5, 2015
  29. laanwj commented at 4:50 pm on November 10, 2015: member
    Concept ACK
  30. jgarzik commented at 4:56 pm on November 10, 2015: contributor
    concept ACK
  31. petertodd force-pushed on Nov 10, 2015
  32. Add opt-in full-RBF to mempool
    Replaces transactions already in the mempool if a new transaction seen
    with a higher fee, specifically both a higher fee per KB and a higher
    absolute fee. Children are evaluateed for replacement as well, using the
    mempool package tracking to calculate replaced fees/size. Transactions
    can opt-out of transaction replacement by setting nSequence >= maxint-1
    on all inputs. (which all wallets do already)
    5891f870d6
  33. Add tests for transaction replacement 0137e6fafd
  34. Prevent low feerate txs from (directly) replacing high feerate txs
    Previously all conflicting transactions were evaluated as a whole to
    determine if the feerate was being increased. This meant that low
    feerate children pulled the feerate down, potentially allowing a high
    transaction with a high feerate to be replaced by one with a lower
    feerate.
    fc8c19a07c
  35. Reject replacements that add new unconfirmed inputs b272ecfdb3
  36. Improve RBF replacement criteria
    Fix the calculation of conflicting size/conflicting fees.
    73d904009d
  37. Add test for max replacement limit 20367d831f
  38. Port test to rpc-test framework 97203f5606
  39. petertodd force-pushed on Nov 10, 2015
  40. petertodd commented at 7:15 pm on November 10, 2015: contributor
    Rebased
  41. petertodd commented at 7:18 pm on November 10, 2015: contributor

    Main question I have right now, is do we want to go with @sdaftuar’s somewhat more complex, but more correct, code? (https://github.com/petertodd/bitcoin/commit/20367d831fe0fdb92678d03552866c266aabbd83) Or keep it simple?

    I’m happy with either way, and the code is written and looks good to me. Just a matter of risk tolerance.

  42. petertodd commented at 7:46 pm on November 10, 2015: contributor
    Also, regarding the duplicated tests, I’m inclined to leave my ones in git history for historical reference in case questions come up later, but delete them from from the codebase soon in favor of @sdaftuar’s. (possibly even in this pull-req) They’re relatively “battle-tested” tests. :)
  43. Fix incorrect locking of mempool during RBF replacement
    Previously RemoveStaged() was called without pool.cs held.
    16a2f93629
  44. petertodd commented at 11:01 pm on November 10, 2015: contributor
    Fixed test failure due to not having pool.cs lock held.
  45. sipa commented at 7:32 am on November 11, 2015: member
    This will enable replacement for BIP68 transactions?
  46. petertodd commented at 10:39 am on November 11, 2015: contributor
    @sipa Yup!
  47. petertodd commented at 10:10 pm on November 11, 2015: contributor
  48. in qa/replace-by-fee/README.md: in 16a2f93629 outdated
    0@@ -0,0 +1,13 @@
    1+Replace-by-fee regression tests
    2+===============================
    3+
    4+First get version v0.5.0 of the python-bitcoinlib library. In this directory
    5+run:
    6+
    7+    git clone -n https://github.com/petertodd/python-bitcoinlib
    


    laanwj commented at 2:13 pm on November 12, 2015:

    I don’t like hard-coding a commit ID here. It will go out of date very soon. If this requires v0.5.x, Can we do something like:

    0git clone --branch 0.5 https://github.com/petertodd/python-bitcoinlib
    

    petertodd commented at 7:03 pm on November 12, 2015:

    My thinking re: hard-coding is reproducability; if we’re out of date, we should explicitly update it rather than implicitly.

    Also, this set of tests will likely get removed fairly soon, and kept just for historical reference now that they’ve been mostly rewritten.

  49. laanwj commented at 3:34 pm on November 12, 2015: member
    Code review ACK
  50. sdaftuar commented at 4:25 pm on November 13, 2015: member

    After further thought I think we can hold the mempool lock for a bit less time. I don’t think it’s possible for transactions to be added or removed from the mempool without holding cs_main, and ATMP holds cs_main the whole time. So I think all we need to do so that the mempool shows a consistent view to any RPC calls that only grab the mempool lock is acquire the lock before calling RemoveStaged(), and release the lock after calling addUnchecked(). (Hopefully someone can verify my reasoning…)

    Anyway I think that’s pretty minor either way.

    ACK.

  51. petertodd commented at 6:57 pm on November 13, 2015: contributor
    @sdaftuar That’s a good point, though I think changing that should be done in a separate pull-req after this is merged.
  52. btcdrak commented at 7:38 pm on November 13, 2015: contributor
    Upgraded to utACK.
  53. dgenr8 commented at 8:10 pm on November 17, 2015: contributor

    Concept ACK, so far is this goes. It can only help to allow spenders to declare their intention not to double-spend, or to keep the option open.

    It will be unfortunate if wallets silently make “replaceable” the default for new transactions. This setting should be exposed and visible, although there are different ways it could be labeled.

    cc @jonasschnelli

  54. luke-jr commented at 8:20 pm on November 17, 2015: member
    In response to @dgenr8 ’s comment, I do think we need to make it very clear that there is still no such thing as technically “declaring an intention not to double-spend”. Strongly prefer adding a full RBF option, even if unwise for miners to deploy today.
  55. petertodd commented at 9:30 pm on November 17, 2015: contributor

    @dgenr8 The nSequence for opt-in is one that no wallets today use by default.

    In any case, indicating an intention not to double-spend isn’t something wallets should really be doing today, given their poor track record of not double-spending; there are many failure modes where wallets today will double-spend a transaction inadvertently, something you can easily see if you watch double-spend logs. This is why any type of doublespend punishment scheme needs to be carefully engineered, and definitely not used with standard wallets.

  56. dgenr8 commented at 10:04 pm on November 17, 2015: contributor

    I think I can phrase my point better. Allowing spenders to declare their intention to double-spend, if they should later so desire, is helpful to 0-conf-accepting receivers because they can be sure not to rely on the transaction before confirmation.

    The 72-hour expiration that will soon be policy is also helpful because it gives a better option to those who have stuck transactions (even those without opt-in RBF set): “wait 72 hours and try again.” This is a lot better than “download @petertodd’s tools,” “use rawtxes,” etc.

  57. jtimon commented at 10:14 pm on November 17, 2015: contributor
    Well, with this you don’t have to wait anything. You can pay more fees at any point to “try again”, that’s kind of the whole point of RBF.
  58. petertodd commented at 1:47 am on November 18, 2015: contributor

    @dgenr8 Does the advice “wait 72 hours and try again” even work right now in Bitcoin Core? IIRC we don’t delete transactions from the wallet itself on that timeout.

    Anyway, while this pull-req doesn’t change any wallet behavior, subsequent pull-reqs of course can of course add the required wallet code to unstick stuck transactions.

  59. dgenr8 commented at 2:58 pm on November 18, 2015: contributor

    @petertodd Opt-in and expiration both suggest new wallet functions:

    On new tx:

    • Mark transaction as replaceable (receiver must wait for confirmation)

    On replaceable or expired unconfirmed tx:

    • Send new version with higher fees
    • Send new version that pays myself instead (permanently cancels original)
    • Forget [release inputs]

    On forgotten transactions with inputs still unspent:

    • Unforget
  60. jtimon commented at 3:59 pm on November 18, 2015: contributor
    @dgenr8 That analysis seems about right. I would personally prefer that the replaceable option was always true (on non-raw transactions, obviously) for Bitcoin Core. But those are changes to the wallet that as explained by @petertodd are out of the scope of this PR.
  61. in src/main.cpp: in 16a2f93629 outdated
     998+                                           hashAncestor.ToString()),
     999+                                 REJECT_INVALID, "bad-txns-spends-conflicting-tx");
    1000+            }
    1001+        }
    1002+
    1003+        // Check if it's economically rational to mine this transaction rather
    


    jtimon commented at 4:08 pm on November 18, 2015:
    Can’t all this new code (1003 to 1140) be a new function? EDIT: since it uses the mempool, it’s probably better that this doesn’t move to policy.cpp yet. In main.cpp is fine, just apart from AcceptToMemoryPool().

    MarcoFalke commented at 2:29 pm on November 20, 2015:
    Agree with @jtimon . It’s hard to read a function spanning over 400 lines not knowing which parts belong together.

    petertodd commented at 8:05 pm on November 20, 2015:

    @jtimon Yeah, it’s tricky though, because we reuse allConflicting later in the removal code for performance, and that in turn requires us to hold a lock; the way the code works isn’t really modularized yet. That said compared to my previous patch we do at least take advantage of other mempool-related code, CalculateDescendants(), so we’re a bit ahead.

    I’d be inclined to leave it as-is right now, and do the refactor later when we add RBF-related code to the wallet and/or RPC - that’s when we’ll have a better idea of what the refactor should look like and how the refactored code should interact with both uses. For instance, the ability to calculate on demand how expensive it would be to replace a specific transaction would be useful.


    jtimon commented at 10:02 am on November 23, 2015:
    I don’t see how is tricky, if you need something inside the new function and in the caller, just pass it as reference. If you were holding the lock, well keep holding it, etc…It should be basically cut the code I said and paste it out as a (for now static) function, and adapt the parameters until it compiles, I think. Of course we can always leave refactors for later, but they often become harder with time (because the code keeps evolving from its current form, not from “what we plan to do with it in a later refactor”. I’m fine with not doing it within this PR (although it would be less disruptive to squash that with the commit that introduces the new code), but I highly dislike when people insist to “postpone refactor X until after feature Y”. If X is ready 6months before Y starts being coded…should we wait there too? That kind of thinking is what has led us to, for example, wait more than 1 year to introduce a CPolicy class (and I’m still waiting because apparently #6068 would be too disruptive for this and other mempool-related changes [I disagree but was tired of rebasing]). If we leave this PR as it is, fine. But please don’t postpone or restrict any kind of development unnecessarily. Complain in the PRs when they exist, but don’t plan how to serialize refactors between features or I predict: new important features will be proposed and the refactors will never happen (and encapsulations will become increasingly hard).

    jtimon commented at 12:48 pm on November 23, 2015:
    I was talking about something like this: https://github.com/jtimon/bitcoin/commit/f10b5317d21eea21375bb0da718dc98ee4e37452 but as said I’m completely fine with not creating the new function yet (although now it would be almost free diff-wise).
  62. CodeShark commented at 2:48 am on November 19, 2015: contributor
    concept ACK, haven’t had time for code review
  63. in src/main.cpp: in 16a2f93629 outdated
    1163+        {
    1164+            LogPrint("mempool", "replacing tx %s with %s for %s BTC additional fees, %d delta bytes\n",
    1165+                    it->GetTx().GetHash().ToString(),
    1166+                    hash.ToString(),
    1167+                    FormatMoney(nFees - nConflictingFees),
    1168+                    (int)nSize - (int)nConflictingSize);
    


    jonasschnelli commented at 8:30 pm on November 19, 2015:

    (maybe out of scope for this PR)

    Do we need a new signal here? How can the wallet detect removed (or replaced) transactions? Maybe the signal needs to be emitted from void CTxMemPool::RemoveStaged(setEntries &stage) (or nearby) to also include the mempool limiting behavior.


    petertodd commented at 7:49 pm on November 20, 2015:
    We probably do. But yeah, I think adding that can wait for another pull-req; belongs as a wallet code change IMO, so might as well let whomever ends up writing that decide what they need.
  64. jonasschnelli commented at 8:32 pm on November 19, 2015: contributor
    CodeReview ACK. (sidenote: it’s always nice to review well documented PRs!)
  65. petertodd commented at 8:06 pm on November 20, 2015: contributor
    @jonasschnelli Thanks! Yeah, apparently my life long dream was actually to become a technical writer, not a programmer. :)
  66. Fix usage of local python-bitcoinlib
    Previously was using the system-wide python-bitcoinlib, if it existed,
    rather than the local copy that you check out in the README.
    63b5840257
  67. in src/main.cpp: in 63b5840257
    1138+            }
    1139+        }
    1140+
    1141         // Check against previous transactions
    1142         // This is done last to help prevent CPU exhaustion denial-of-service attacks.
    1143         if (!CheckInputs(tx, state, view, true, STANDARD_SCRIPT_VERIFY_FLAGS, true))
    


    jtimon commented at 12:16 pm on November 23, 2015:
    Wouldn’t it be better to put the new code (from L987) after this check instead of before? It would avoid doing further mempool validations for transactions that are going to be rejected by this check anyway. I know there can be transactions that would pass this check but be rejected as a replacement, but this check already has the inputs of the transaction cached, so it seems cheaper than the RBF logic and it makes sense to me to do it first. Note that this minor nit wouldn’t change the total diff (although it can be done later with other changes too [for example, a rebased #6445 ]).

    petertodd commented at 5:58 pm on November 25, 2015:
    You mean after the CheckInputs() line? The RBF code is just a bunch of pointer following of in-memory data, with limited depth and breadth, so it shouldn’t be expensive code to run - remember that the mempool has tx fee and size data in the CTxMemPool structs.

    jtimon commented at 6:03 pm on November 25, 2015:
    Never mind, I misread this line for AreInputsStandard().
  68. dcousens commented at 1:13 am on November 26, 2015: contributor

    Is a higher sequence number still preferred? In the case of a fee tie?

    specifically both a higher fee per KB and a higher absolute fee

    Or only the higher fee?

    What is the behaviour if a transaction is broadcast with the sequence number 0xffffffff after a transaction was already found that was ‘opt-in’?

  69. petertodd commented at 1:16 am on November 26, 2015: contributor

    @dcousens Just higher fee. Ties get rejected to avoid them being used as a way to waste bandwidth.

    If a nSequence > maxint-2 transaction is broadcast it is subject to the same rules as any other replacement; it won’t get accepted without paying a (sufficiently) higher fee. That said, if it is accepted further replacements will be rejected. The replacement behavior is stateless, acting only on what is in the mempool right now.

  70. dcousens commented at 1:54 am on November 26, 2015: contributor
    Thanks for clarifying that @petertodd :+1: @kristovatlas I wonder if the ‘default’ sequence number when opting into RBF should just be 0 then? Just thinking of the privacy implications.
  71. petertodd commented at 2:00 am on November 26, 2015: contributor
    @dcousens nSequence=0 makes sense from the perspective of https://github.com/bitcoin/bips/blob/master/bip-0068.mediawiki too.
  72. laanwj merged this on Nov 27, 2015
  73. laanwj closed this on Nov 27, 2015

  74. laanwj referenced this in commit 0e935865b9 on Nov 27, 2015
  75. kristovatlas commented at 10:31 pm on November 27, 2015: none
    @dcousens defaulting to nSequence=0 for the purpose of reducing wallet client fingerprintability makes sense to me.
  76. braydonf referenced this in commit f1d19b438e on Dec 9, 2015
  77. laanwj referenced this in commit 44757729a4 on Feb 24, 2016
  78. laanwj referenced this in commit 8fc81e0983 on Feb 24, 2016
  79. makevoid referenced this in commit 596a2f5ad3 on Jun 13, 2016
  80. in src/main.cpp: in 63b5840257
    1023+                if (mi == pool.mapTx.end())
    1024+                    continue;
    1025+
    1026+                // Save these to avoid repeated lookups
    1027+                setIterConflicting.insert(mi);
    1028+
    


    rebroad commented at 8:08 am on August 25, 2016:
    The following was later removed by #7594
  81. ryanxcharles referenced this in commit e6d055f914 on Jun 3, 2020
  82. MarcoFalke locked this on Sep 8, 2021

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2024-12-19 03:12 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me