[0.12] Backport BIP9, BIP68 and BIP112 with softfork #7543

pull btcdrak wants to merge 23 commits into bitcoin:0.12 from btcdrak:dot12_backport_bip68 changing 39 files +2735 −85
  1. btcdrak commented at 9:11 PM on February 16, 2016: contributor

    Backport of #7184 (BIP68), #7524 (BIP112), #7187 (lockpoints), #7575 (BIP9) and #7648 (softfork) for 0.12.

    EDIT: added #7531 (one line add test to extendedTests array and trivial comment edit #7773

  2. jonasschnelli added the label Feature on Feb 19, 2016
  3. jonasschnelli added the label Mempool on Feb 19, 2016
  4. morcos commented at 9:11 PM on February 19, 2016: member

    ACK on this being the correct backport, but I would prefer to see 1 pull with the soft fork logic and all accompanying implementations backported at the same time. I think it would be much safer to test and review it together like that. Lets wait until we have the soft fork logic finished and merged.

  5. btcdrak renamed this:
    Backport BIP68 implementation for 0.12
    Backport BIP68 and BIP112 implementation for 0.12
    on Mar 15, 2016
  6. btcdrak renamed this:
    Backport BIP68 and BIP112 implementation for 0.12
    Backport BIP68 and BIP112 mempool logic for 0.12
    on Mar 15, 2016
  7. btcdrak renamed this:
    Backport BIP68 and BIP112 mempool logic for 0.12
    [0.12] Backport BIP68 and BIP112 mempool only
    on Mar 15, 2016
  8. btcdrak commented at 8:24 PM on March 16, 2016: contributor

    I added #7187 to this backport.

  9. btcdrak force-pushed on Mar 18, 2016
  10. Implement SequenceLocks functions
    SequenceLocks functions are used to evaluate sequence lock times or heights per BIP 68.
    
    The majority of this code is copied from maaku in #6312
    Further credit: btcdrak, sipa, NicolasDorier
    15ba08c3b5
  11. Add RPC test exercising BIP68 (mempool only) 0d09af77b7
  12. Bug fix to RPC test 0a79c04af3
  13. fix sdaftuar's nits again
    it boggles the mind why these nits can't be delivered on a more timely basis
    197c3760ff
  14. BIP112: Implement CHECKSEQUENCEVERIFY
    - Replace NOP3 with CHECKSEQUENCEVERIFY (BIP112)
      <nSequence> CHECKSEQUENCEVERIFY -> <nSequence>
    - Fails if txin.nSequence < nSequence, allowing funds of a txout to be locked for a number of blocks or a duration of time after its inclusion in a block.
    - Pull most of CheckLockTime() out into VerifyLockTime(), a local function that will be reused for CheckSequence()
    - Add bitwise AND operator to CScriptNum
    - Enable CHECKSEQUENCEVERIFY as a standard script verify flag
    - Transactions that fail CSV verification will be rejected from the mempool, making it easy to test the feature. However blocks containing "invalid" CSV-using transactions will still be accepted; this is *not* the soft-fork required to actually enable CSV for production use.
    c0c5e09fe2
  15. Separate CheckLockTime() and CheckSequence() logic
    For the sake of a little repetition, make code more readable.
    6170506fdf
  16. Code style fix.
    This if statement is a little obtuse and using braces here
    improves readability.
    c8d309e4b4
  17. Add LockPoints
    Obtain LockPoints to store in CTxMemPoolEntry and during a reorg, evaluate whether they are still valid and if not, recalculate them.
    ade85e126d
  18. BIP9 Implementation
    Inspired by former implementations by Eric Lombrozo and Rusty Russell, and
    based on code by Jorge Timon.
    6f83cf2adb
  19. Versionbits tests 5f90d4e294
  20. Softfork status report in RPC 0bdaacd791
  21. Add testing of ComputeBlockVersion 8ebc6f2aac
  22. Test versionbits deployments 0710b303d6
  23. RPC test for BIP9 warning logic 6ff0b9f96e
  24. btcdrak force-pushed on Mar 18, 2016
  25. Add CHECKSEQUENCEVERIFY softfork through BIP9 ee40924fef
  26. Soft fork logic for BIP113 648be9b442
  27. Soft fork logic for BIP68 9713ed3015
  28. Policy: allow transaction version 2 relay policy.
    This commit introduces a way to gracefully bump the default
    transaction version in a two step process.
    159ee3dd90
  29. Add RPC test for BIP 68/112/113 soft fork.
    This RPC test will test both the activation mechanism of the first versionbits soft fork as well as testing many code branches of the consensus logic for BIP's 68, 112, and 113.
    3a99feba85
  30. btcdrak renamed this:
    [0.12] Backport BIP68 and BIP112 mempool only
    [0.12] Backport BIP9, BIP68 and BIP112 with softfork
    on Mar 18, 2016
  31. morcos commented at 7:02 PM on March 18, 2016: member

    ACK 3a99feb (backported myself and got the same code)

  32. laanwj added the label Consensus on Mar 18, 2016
  33. Test of BIP9 fork activation of mtp, csv, sequence_lock 26e9a05cc3
  34. btcdrak force-pushed on Mar 26, 2016
  35. sipa commented at 10:38 AM on March 28, 2016: member

    Mechanical backport check ACK 26e9a05cc3192ce19b7c46043aeb12230d3207a5

    Ran the following script:

    while read F L; do git show $F | egrep -v '^index ' | egrep -v '^commit ' | egrep -v '^@@ ' >/tmp/f; git show $L | egrep -v '^index ' | egrep -v '^commit ' | egrep -v '^@@ ' >/tmp/l; diff /tmp/f /tmp/l; done
    

    with input: 12c89c918534f8e615e80381b692d89d6b09d174 159ee3dd90490eabf6c048c17a62ffa01f6a0967 02c243580295a7f1c0298fcd9afc2e76b607e724 9713ed3015da02b0132b665e965fd591689e6510 478fba6d5213a3f1ffeca5feeacf28aaf6844fd6 648be9b442587cc1682052bca80625aea906a01d 65751a3cf2421a9419172949cad9dc49b7383551 ee40924fef1e8835b9ef865360b126952ad8359d d23f6c6a0d2dc8a3f5f159faf7a40157259a8f8f 0bdaacd7913fd626691daa2946590547071dcf3b 6851107b3a52ec869e5e3a2cb4eb02d6c743b8e5 6f83cf2adb2fd73cfeaa8ef67054ea8a0e4ef4db 982670c333aff6d5660c18ed00931df764733529 ade85e126d1ba7cb90a3382fb8c3cc4f3b89dc4d a38107643f3f01cd92a4e6da9e7a9d025770ff37 c8d309e4b4d82dd233f167b4df503e6a5b4164ef c3c375226ebf98901849593b8ebfe8e8b69895c2 6170506fdf920e1cb07c086be670ad624cb04241 53e53a33c939949665f60d5eeb82abbb21f97128 c0c5e09fe2166a0b8ea6fc1f13e131e3ba8df478 b043c4b746c8199ce948aa5e8b186e0d1a61ad68 197c3760ff07daeecbb726a0cfef899502520ee5 15ba08c3b5f66a6c4726a746affc7fb3216d4206 c6c2f0fd782ccf607027414012f45c8f48561a30

    (the corresponding non-test commits)

    The output is:

    29c29
    <              return state.DoS(10, false, REJECT_INVALID, "bad-txns-nonfinal", false, "non-final transaction");
    ---
    >              return state.DoS(10, error("%s: contains a non-final transaction", __func__), REJECT_INVALID, "bad-txns-nonfinal");
    68,70c68,70
    < diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp
    < --- a/src/rpc/blockchain.cpp
    < +++ b/src/rpc/blockchain.cpp
    ---
    > diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp
    > --- a/src/rpcblockchain.cpp
    > +++ b/src/rpcblockchain.cpp
    40,42c40,42
    < diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp
    < --- a/src/rpc/blockchain.cpp
    < +++ b/src/rpc/blockchain.cpp
    ---
    > diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp
    > --- a/src/rpcblockchain.cpp
    > +++ b/src/rpcblockchain.cpp
    12d11
    <    utilmoneystr.h \
    14a14
    >    version.h \
    18c18
    <    wallet/rpcwallet.h \
    ---
    >    wallet/wallet.h \
    

    which is good, as there are no lines starting with '+' or '-' that changed between the diffs.

  36. instagibbs commented at 2:08 PM on March 28, 2016: member
  37. Add bip68-sequence.py to extended rpc tests caf138122d
  38. btcdrak commented at 9:36 AM on March 29, 2016: contributor

    cherry-picked #7531 6ba8b2a6c4d1bc393dd7c4734090a4c0dfa750c2 as caf1381 - one line including bit68-sequence.py in extended tests array.

  39. sdaftuar commented at 3:26 PM on March 30, 2016: member

    ACK caf138122decac7d96b2f53c0c894277cb0f33ca

  40. jl2012 commented at 4:02 PM on March 30, 2016: contributor

    backport matches, tACK caf1381

  41. btcdrak commented at 9:28 AM on March 31, 2016: contributor

    Added trivial comment edit from #7773 as c270b62

  42. Fix comments in tests c270b62cc2
  43. petertodd commented at 7:23 PM on March 31, 2016: contributor

    utACK

  44. in qa/rpc-tests/bip9-softforks.py:None in c270b62cc2 outdated
      89 | +        # generate some coins for later
      90 | +        self.coinbase_blocks = self.nodes[0].generate(2)
      91 | +        self.height = 3  # height of the next block to build
      92 | +        self.tip = int ("0x" + self.nodes[0].getbestblockhash() + "L", 0)
      93 | +        self.nodeaddress = self.nodes[0].getnewaddress()
      94 | +        self.last_block_time = time.time()
    


    MarcoFalke commented at 12:50 PM on April 2, 2016:

    This should explicitly be int. Sadly, py2 will silently cast the float to int where needed.

  45. in qa/rpc-tests/bip68-sequence.py:None in c270b62cc2 outdated
      60 | +        assert(len(utxos) > 0)
      61 | +
      62 | +        utxo = utxos[0]
      63 | +
      64 | +        tx1 = CTransaction()
      65 | +        value = satoshi_round(utxo["amount"] - self.relayfee)*COIN
    


    MarcoFalke commented at 12:51 PM on April 2, 2016:

    This should be int. (see previous comment)

  46. in qa/rpc-tests/bip68-sequence.py:None in c270b62cc2 outdated
     179 | +                        sequence_value |= SEQUENCE_LOCKTIME_TYPE_FLAG
     180 | +                tx.vin.append(CTxIn(COutPoint(int(utxos[j]["txid"], 16), utxos[j]["vout"]), nSequence=sequence_value))
     181 | +                value += utxos[j]["amount"]*COIN
     182 | +            # Overestimate the size of the tx - signatures should be less than 120 bytes, and leave 50 for the output
     183 | +            tx_size = len(ToHex(tx))/2 + 120*num_inputs + 50
     184 | +            tx.vout.append(CTxOut(value-self.relayfee*tx_size*COIN/1000, CScript([b'a'])))
    


    MarcoFalke commented at 12:51 PM on April 2, 2016:

    the first arg to CTxOut should be int explicitly (see previous comment).

  47. MarcoFalke commented at 12:51 PM on April 2, 2016: member

    utACK c270b62. My nits can be fixed later

  48. NicolasDorier commented at 2:22 PM on April 2, 2016: contributor

    utACK, checked with sipa's script

  49. [qa] rpc-tests: Properly use integers, floats
    partial backport from #7778 using fa2cea1
    640666b22f
  50. in qa/rpc-tests/bip68-sequence.py:None in 94c68e18d2 outdated
     180 | @@ -181,7 +181,7 @@ def test_sequence_lock_confirmed_inputs(self):
     181 |                  value += utxos[j]["amount"]*COIN
     182 |              # Overestimate the size of the tx - signatures should be less than 120 bytes, and leave 50 for the output
     183 |              tx_size = len(ToHex(tx))/2 + 120*num_inputs + 50
     184 | -            tx.vout.append(CTxOut(value-self.relayfee*tx_size*COIN/1000, CScript([b'a'])))
     185 | +            tx.vout.append(int(CTxOut(value-self.relayfee*tx_size*COIN/1000, CScript([b'a']))))
    


    MarcoFalke commented at 4:17 PM on April 3, 2016:

    I'd be surprised if this worked. (You are passing the CTxOut into int())

    Edit: You could just try a git cherry-pick ...; git reset HEAD~; git commit qa/rpc-tests/bip*


    btcdrak commented at 5:06 PM on April 3, 2016:

    Fixed.

  51. btcdrak force-pushed on Apr 3, 2016
  52. btcdrak commented at 5:08 PM on April 3, 2016: contributor

    @MarcoFalke I cherry-picked your int/float fixes for RPC tests, from #7778 commit fa2cea1 in 640666b

  53. MarcoFalke commented at 5:09 PM on April 3, 2016: member

    utACK 640666b

  54. laanwj merged this on Apr 4, 2016
  55. laanwj closed this on Apr 4, 2016

  56. laanwj referenced this in commit 834aaef7bd on Apr 4, 2016
  57. afk11 commented at 1:37 PM on April 4, 2016: contributor

    ACK 3a99feb

  58. btcdrak deleted the branch on Dec 3, 2016
  59. DrahtBot 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: 2026-04-16 18:15 UTC

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