CHECKLOCKTIMEVERIFY (BIP65) IsSuperMajority() soft-fork #6351

pull petertodd wants to merge 3 commits into bitcoin:master from petertodd:cltv-is-super-majority-soft-fork changing 7 files +285 −5
  1. petertodd commented at 7:17 pm on June 28, 2015: contributor

    Final step towards CLTV deployment on mainnet.

    I’ve copied the logic and tests from the previous BIP66 (DERSIG) soft-fork line-by-line for ease of review; any code review applicable to BIP66 should be applicable to BIP65.

    Once merged I’ll prepare a backport of the soft-fork logic for the v0.10.x branch as well.

  2. jonasschnelli commented at 11:06 am on June 29, 2015: contributor

    IMO bip65-cltv-p2p.py should be included in extended list in pull-tester/rpc-tests.sh. Adding it in the “normal” not extended list makes not much sense even if the script execution time is acceptable (<1min on a decent system).

    Tested ACK.

  3. jtimon commented at 12:24 pm on June 29, 2015: contributor
    I didn’t reviewed the python tests, just the c++ part, but utACK on that part.
  4. btcdrak commented at 12:31 pm on June 29, 2015: contributor
    utACK
  5. petertodd force-pushed on Jun 29, 2015
  6. petertodd commented at 11:33 pm on June 29, 2015: contributor
    @jonasschnelli Added the tests to the extended list. I didn’t actually know about the pull-tester test list before, thanks!
  7. in qa/rpc-tests/bip65-cltv.py: in 1706aa084c outdated
    65+
    66+        # Mine 1 new-version blocks
    67+        self.nodes[2].generate(1)
    68+        self.sync_all()
    69+        if (self.nodes[0].getblockcount() != cnt + 1051):
    70+            raise AssertionError("Failed to mine a version=3 block")
    


    mruddy commented at 0:25 am on July 1, 2015:
    Line 70 should be: Failed to mine a version=4 block

    petertodd commented at 9:30 pm on July 1, 2015:
    Fixed.
  8. in qa/rpc-tests/bip65-cltv.py: in 1706aa084c outdated
    38+            self.nodes[2].generate(50)
    39+        self.sync_all()
    40+        if (self.nodes[0].getblockcount() != cnt + 850):
    41+            raise AssertionError("Failed to mine 750 version=4 blocks")
    42+
    43+        # TODO: check that new CHECKLOCKTIMEVERIFY rules are not enforced
    


    mruddy commented at 0:44 am on July 1, 2015:
    In order to fill out the test for this “not enforced” TODO, you’ll need to add a testable transaction to the 750th v4 block. As in your other script, you’d want to check that the new CLTV rules are not enforced on the 750th v4 block and that they are enforced on the 751st v4 block.
  9. in qa/rpc-tests/bip65-cltv-p2p.py: in 1706aa084c outdated
    0@@ -0,0 +1,175 @@
    1+#!/usr/bin/env python2
    2+#
    


    mruddy commented at 0:47 am on July 1, 2015:
    minor nit, just noticed that the copyright header was different in this file than the other
  10. mruddy commented at 0:55 am on July 1, 2015: contributor

    Looks pretty good. Minor todo’s with the python test scripts.

    Needs some release notes, but you might have been waiting on those until later in the process. When you get to them, perhaps add a disclaimer that we may change the OP_NOP2 name decode to OP_CHECKLOCKTIMEVERIFY in script “asm” outputs in the future. That way we’ll have the flexibility to make that change if/when we get to it.

  11. petertodd commented at 9:35 pm on July 1, 2015: contributor

    So, @mruddy brought up two issues that are really the same as with the BIP66 tests: out of date copyright headers and TODO items that are out of date. The latter issue is pretty simple: bipdersig-p2p.py covers the missing test cases marked as “TODO” in bipdersig.py

    I wanted to show I’ve replicated the exact same testing procedure done on BIP66 given that the code changes itself are also replicated exactly; if I’m going to fix these two nits I think it makes sense to fix them in the BIP66 tests first, in a separate commit that’ll go first in this pull-req, so the two sets of tests can still be diffed directly to show exact equivalence. Makes sense? @mruddy Yup, I’ll add release notes later, and similarly, will look at what changing the NOP2 name will entail later. Right now I’m focused on making the minimal possible change that gets the job done so backporting the changes to v0.10.x (and probably v0.11.x) will be easy and clearly correct. v0.12.x can do the more invasive stuff of changing opcode names and what-not.

  12. petertodd force-pushed on Jul 1, 2015
  13. mruddy commented at 12:13 pm on July 2, 2015: contributor

    @petertodd I see what you’re saying about trying to keep the diff compares as close and easy as possible. But, the diffs on the tests are necessarily going to be somewhat different. I wouldn’t make updated BIP66 test cases part of this change set. My choice would be to make the minor cleanups to these tests so that they are cleaner when reviewed in isolation (and in the future, not within the context of how this change set compares to that of BIP66). I can see how line-only diffs vs some block or structural diffs might have some value to reduce dissonance though. So, however you want to handle it is OK with me.

    About the decode name update, I agree, leave that until later. I was just saying that if you mention the upcoming change in the notes now, then it makes actually pushing it through later, easier. It’s more of a busy work change anyways, so leave it for someone newer to the project than yourself to work on. It’s good for someone newer to work on because of how it may affect various parts of the code base.

  14. laanwj added the label Validation on Jul 3, 2015
  15. petertodd commented at 6:16 am on July 4, 2015: contributor

    @mruddy Thanks! It’d be awesome for you to do that, and it’d be a good opportunity to have more eyes on the code too of course.

    Anyway, I’ll see what the other reviewers think re: the tests.

  16. mruddy commented at 6:14 pm on July 4, 2015: contributor
    I probably will, it’s on my todo list.
  17. mruddy commented at 9:48 am on August 2, 2015: contributor
    What do we need to do now to move this forward? Is this waiting on coordination with some other work, in need of more testing, or just baking and giving time for more review (it’s been about a month since last update)?
  18. in src/main.cpp: in 3082578560 outdated
    1854         flags |= SCRIPT_VERIFY_DERSIG;
    1855     }
    1856 
    1857+    // Start enforcing CHECKLOCKTIMEVERIFY, (BIP65) for block.nVersion=4
    1858+    // blocks, when 75% of the network has upgraded:
    1859+    if (block.nVersion >= 4 && IsSuperMajority(4, pindex->pprev, chainparams.GetConsensus().nMajorityEnforceBlockUpgrade, chainparams.GetConsensus())) {
    


    jtimon commented at 11:00 am on August 4, 2015:
    I still don’t know why we wait for 75% to start using a policy rule. I would do it from the start but only enforce it as a consensus rule after 95%. I don’t want to slow this down since it is a general softfork question (even if I’m right it can be solved after this PR), but I haven’t been able to find an answer anywhere.

    sipa commented at 4:40 pm on August 4, 2015:
    This is not a policy rule.

    jtimon commented at 5:41 pm on August 4, 2015:
    While individual miners apply it but still not enforce it as a consensus rule (ie reject blocks that don’t apply it), it is just mining policy. What am I missing?

    jtimon commented at 11:42 am on October 15, 2015:
    Seriously, what am I missing here? Why wait for 75% for enforcing the new rule in your own blocks (which by the way you are marking as being version 4)?

    petertodd commented at 6:25 am on October 16, 2015:

    This code is executed against all blocks, not just blocks you created. If another miner creates a nVersion=4 block with an invalid use of CHECKLOCKTIMEVERIFY if you reject it without a majority of hashing power also rejecting it you’ll get forked.

    In fact, it might be a good idea to go the other way and remove the 75% rule, accepting invalid nVersion=4 blocks until 95%


    jtimon commented at 11:05 am on October 16, 2015:
    Thanks, for some reason I was fixated on this 75% threshold only affecting your own blocks, but this is ConnectBlock so it obviously affects all blocks. Yes, I wouldn’t oppose to wait for the 95% here too. But with versionbits this disappears so is probably not worth to discuss this much.

    petertodd commented at 12:08 pm on October 16, 2015:
    Yeah, I probably would have changed it to remove 75% a year ago… but at this stage I think it’s harmless to leave in.
  19. jtimon commented at 11:04 am on August 4, 2015: contributor
    @mruddy I would say that, as usual, we’re just waiting for more review, but IMO the harder-to-review parts have already been merged. I would really like that we move forward on this.
  20. petertodd commented at 11:06 am on August 4, 2015: contributor

    I think what’s holding this up is a lack of political will to do yet another non-nVersion bits soft-fork upgrade; @gmaxwell has indicated a strong preference for never using IsSuperMajority() again.

    On 4 August 2015 07:04:50 GMT-04:00, “Jorge Timón” notifications@github.com wrote:

    @mruddy I would say that, as usual, we’re just waiting for more review, but IMO the harder-to-review parts have already been merged. I would really like that we move forward on this.


    Reply to this email directly or view it on GitHub: #6351 (comment)

  21. btcdrak commented at 4:20 pm on August 4, 2015: contributor
    It would seem a better plan to deploy this softfork now rather than waiting for nVersionbits code which isnt done yet. We know this method works and it doesnt get in the way of nVersionbits deployment later. Many players in the ecosystem are waiting for CLTV, I dont see why we should wait for perfection when we can deploy a much anticipated feature now. @sipa @gmaxwell @laanwj
  22. jl2012 commented at 5:39 pm on August 4, 2015: contributor

    Do we have any softfork ready to deploy in the coming 4 months? If no I don’t think we need to wait for nVerionbits. I guess BIP62 is not ready yet.

    Is there any plan to prevent a fork due to reckless SPV mining?

    By the way, if BIP101 is implemented in Bitcoin XT, blocks will have a version number with bits 1,2,3 and 14 set (0x20000007 in hex). In that case, it is not possible to support BIP101 without also supporting BIP65. @gavinandresen @mikehearn

  23. btcdrak commented at 10:44 pm on August 4, 2015: contributor
    Just for the record, @sipa ACK’d for IsSuperMajority() on the ML
  24. dcousens commented at 1:29 am on August 5, 2015: contributor

    @gmaxwell has indicated a strong preference for never using IsSuperMajority() again. @gmaxwell can you confirm this?

  25. maaku commented at 4:45 pm on August 5, 2015: contributor
    @dcousens this pull request shouldn’t be held up waiting for a response from someone who has never participated in it. @jl2012 there is BIP68, and the as-yet unnumbered CHECKSEQUENCEVERIFY and median-lock-time-past BIPs, all of which are related to CHECKTIMELOCKVERIFY and could be rolled out together…
  26. jl2012 commented at 1:02 pm on August 6, 2015: contributor
    @maaku I think we could go with IsSuperMajority(). If BIP68 or other related BIPs are ready before BIP65 is completed, they could be considered as “addon” of BIP65. People will use nVersion=5 to support BIP65 and those addon.
  27. btcdrak commented at 10:41 pm on August 6, 2015: contributor

    @maaku I was thinking the same thing recently that rolling out CLTV and CSV opcodes as one upgrade would be ideal and most efficient but when are you planning to make the PR for CSV? Seems like the code is there in your fork…

    If this is going to take you a while then in my opinion we should not hold up CLTV, but I think it would be a wasted opportunity not to bundle the features you list as one soft-fork.

  28. maaku commented at 10:50 pm on August 6, 2015: contributor

    The code is done, ready, tested, deployed to alpha testnet and known to work.

    What remains to be done is writing a BIP… Assistance is welcome if someone wants to help speed this along. I’m being pulled in 10 different directions and having trouble allocating the time necessary.

    On Thu, Aug 6, 2015 at 3:42 PM, ฿tcDrak notifications@github.com wrote:

    @maaku https://github.com/maaku I was thinking the same thing recently that rolling out CLTV and CSV opcodes as one upgrade would be ideal and most efficient but when are you planning to make the PR for CSV? Seems like the code is there in your fork…

    If this is going to take you a while then in my opinion we should not hold up CLTV, but I think it would be a wasted opportunity not to bundle the features you list as one soft-fork.

    — Reply to this email directly or view it on GitHub #6351 (comment).

  29. jtimon commented at 10:58 pm on August 6, 2015: contributor
    +1 to @btcdrak ’s thoughts.
  30. TheBlueMatt commented at 4:36 pm on August 8, 2015: member
    Concept ACK and +1 to @btcdrak. I’d suggest holding off merging this until either CSV is ready or a week or two before a new release is going to freeze.
  31. chriswheeler referenced this in commit a3f4f0b868 on Aug 10, 2015
  32. NicolasDorier commented at 3:54 pm on August 13, 2015: contributor
    +1 for @btcdrak would be awesome
  33. jl2012 commented at 2:41 am on August 19, 2015: contributor

    Slush has found the first version 0x20000007 block on the mainnet. So there are only two options left for BIP65: 1. adopt the “version bit” BIP; 2. Use IsSuperMajority with vserion>0x20000007

    Otherwise, there may be a premature birth of BIP65

    In this case, I don’t support IsSuperMajority as it will permanently invalidate a large range of nVersion

  34. btcdrak commented at 2:52 am on August 19, 2015: contributor
    @jl2012 You could also mask away bits 1,2,3, and 14 and have an integer comparison with blockversion>=8.
  35. jl2012 commented at 3:02 am on August 19, 2015: contributor
    @btcdrak I guess masking only bit 14 is enough? So one has to set bits 1,2,3,4 and 14 to support both BIP65 and BIP101? And bit 4 for BIP65 only?
  36. btcdrak commented at 8:10 am on August 19, 2015: contributor
    @jl2012 By masking out 1,2,3 and 14 and nVersion=8 can be tested to be >=4 without wasting a bit for whenever we do adopt versionbits softfork signalling.
  37. jgarzik commented at 1:34 pm on September 16, 2015: contributor
    concept ACK. Big fan of CLTV and its benefits.
  38. dcousens commented at 3:13 pm on September 16, 2015: contributor
    concept ACK here too. I have been waiting on this to be merged for a while now. Anything blocking it? (other than the soft-fork)
  39. petertodd commented at 8:38 pm on September 16, 2015: contributor

    FWIW currently BIP101/XT’s nVersion bits aren’t a concern to me, as the adoption is low enough to not trigger accidentally. Also, @gavinandresen confirmed w/ other devs recently that they’ll add CLTV support to XT.

    In terms of deployment, this IsSuperMajority() deployment mechanism is well tested and works, and there’s no compatibility issue with it and a future nVersion bits deployment. (or subsequent IsSuperMajority() soft-forks) The only issue is if CLTV fails to gain acceptance, which right now I think is very unlikely.

    So, ACK merge to get CLTV deployment on-track and in-progess.

  40. btcdrak commented at 8:44 pm on September 16, 2015: contributor
    I would prefer to wait for the other locktime PRs to be merged and soft fork them in as a bundle.
  41. petertodd commented at 8:58 pm on September 16, 2015: contributor

    @btcdrak So basically IMO the advantage of that approach is it results in fewer overall # of soft-forks. Personally I’m kinda “meh” on that, but it’s a reasonable position to hold.

    Re: my schedule, I’m going to try to spend a day or two next week with the other locktime soft-forks and do a code review.

    What I am a rather dubious about, is waiting until nVersion bits is finished, given that code hasn’t even begun to be written yet - there’s enough consensus for CLTV certainly to do another IsSuperMajority() soft-fork and get it there.

  42. petertodd commented at 8:59 pm on September 16, 2015: contributor
    tl;dr: For deploying CLTV, lets not let perfect be the enemy of good…
  43. maaku commented at 10:35 pm on September 16, 2015: contributor

    The only outstanding question on the other LT bips is whether there is sufficient justification to save some extra soft-fork bits in the sequence field, which has a somewhat messy solution. I’m available to do what is necessary to get these merged.

    Oh, and ACK on merging this, version bits or no, but like @btcdrak would prefer the 4 lock time bips were done together.

  44. btcdrak commented at 10:37 pm on September 16, 2015: contributor

    @petertodd I’m definitely not suggesting to wait for Versionbits proposal. If it’s ready before the 0.12 release then of course we should use it, but otherwise we should deploy using IsSuperMajority().

    Ideally we deploy CLTV+CSV(etc), unless they are not ready then we just go with CLTV. Until then, I would defer on merging this.

  45. dcousens commented at 11:19 pm on September 16, 2015: contributor

    Ideally we deploy CLTV+CSV(etc), unless they are not ready then we just go with CLTV. Until then, I would defer on merging this.

    ACK, but I’d prefer we had a hard time line on this, say, if CSV isn’t ready by the end of the month, then just push forward with CLTV alone?

  46. btcdrak commented at 11:23 pm on September 16, 2015: contributor
    @dcousens While I think the locktime PRs are very nearly ready, I believe the right cutoff would be before the feature freeze of 0.12 (which wont be that far off anyway if we’re following avg 6 months between major releases). What we really need to do is rally people to review #6566, #6312 and #6564
  47. dcousens commented at 11:36 pm on September 16, 2015: contributor
    @btcdrak that sounds like a good plan. I forgot about the release cycle. I’ve added those PRs to my to-review list, and suspect I’ll read through them before the end of the week.
  48. maaku commented at 3:47 am on September 17, 2015: contributor

    @dcousens be aware that #6312 / BIP 68 has two alternative implementations that are under consideration:

    #6312 (comment)

    #6564 would have to be correspondingly adjusted. The remaining decision that needs to be made is which of these two branches we move forward with.

  49. jtimon commented at 4:10 am on September 17, 2015: contributor

    @petertodd I’m definitely not suggesting to wait for Versionbits proposal. If it’s ready before the 0.12 release then of course we should use it, but otherwise we should deploy using IsSuperMajority().

    Ideally we deploy CLTV+CSV(etc), unless they are not ready then we just go with CLTV. Until then, I would defer on merging this.

    ACK this plan.

  50. laanwj commented at 7:54 pm on September 29, 2015: member

    Looks good to me /. utACK

    Nit: getblockchaininfo RPC in rpcblockchain.cpp needs to be updated to report this softfork as well, This is a trivial code change, but will allow users to see how far the fork is along.

  51. maaku commented at 4:54 pm on September 30, 2015: contributor

    NACK as-is. The optics, communication difficulties, and extra work of pulling off multiple lock-time related soft-forks are not being properly considered.

    #6312 was proposed three months ago and has seen a good deal of review. The much simpler and less controversial #6564 and #6566 have been open for a month. Together these constitute a complete upgrade to the behavior of lock-time in bitcoin. Rolling out CLTV first will cause head-aches. In particular #6566 changes how lock-time validity is determined. Having to go back and fix infrastructure written against the current behavior if/when #6566 is rolled out will be a giant waste of everyone’s time.

    There was a plan discussed on the mailing list, this very issue, and the IRC development meeting a week ago to get reviews of the above mentioned PR’s and do a point release just prior to 0.12. What happened to that plan?

  52. jtimon commented at 6:08 pm on September 30, 2015: contributor

    @maaku I thought we already had a plan:

    1. Merge this before 0.12
    2. If nVersion bits is ready on time, deploy it using nVersion bits.
    3. If the maturity/rcltv/csv BIPs PRs are ready on time, deploy them all as a single softfork.

    I believe we still have time to make all these 3 things for 0.12, I hope I’m not too optimistic. But if we are not able to do so, I don’t think BIP65 should wait more. I know softforks/hardforks don’t need to coincide with major releases, but still, I don’t see the problem with rolling the 2 changes in 2 different softforks if necessary. You mention that #6566 changes how lock time validity is determined. Maybe some of that can be incorporated to BIP65 to safe the later head-aches?

  53. petertodd commented at 6:26 pm on September 30, 2015: contributor
    @maaku CLTV is written in such a way as to not change any of the semantics of anything other than OP_NOP2; whether or not CLTV is implemented has no bearing on CSV. Also, the statement “Together these constitute a complete upgrade to the behavior of lock-time in bitcoin.” is incorrect: the upgrade is to the behavior of nSequence only. The behavior of nLockTime - and hence CLTV - remains unchanged. (modulo the median time soft-fork, which again being a soft-fork is independent of CLTV and the CLTV codebase itself)
  54. maaku commented at 6:27 pm on September 30, 2015: contributor
    @petertodd I request that you please review #6566.
  55. petertodd commented at 6:35 pm on September 30, 2015: contributor

    @maaku I have looked at it. Like I say, whether or not CLTV is implemented has no impact on it.

    Remember the only thing this pull-req does is enforce CLTV during block validation - code that already exists in git HEAD. CSV is a separate issue. For that matter, the unit tests for CLTV don’t even change with any of these proposed changes!

  56. btcdrak commented at 10:03 pm on September 30, 2015: contributor
    @jtimon Beginning the CLTV softfork now would only speed up CLTV deployment by a couple of months tops, which makes no sense to me if we can get the remaining locktime PRs merged in that same timeframe. But what is clear, is CLTV needs to be ready to go if CSV isnt ready in time. We should discuss this at the next dev meeting.
  57. jtimon commented at 10:23 pm on September 30, 2015: contributor
    @btcdrak I believe it was you who wrote the plan I explain above and I acked that plan #6351 (comment)
  58. petertodd commented at 3:53 pm on October 1, 2015: contributor
    @laanwj Re: your nit, I’ll fix that once this is merged, because #6707 (comment)
  59. CodeShark commented at 12:14 pm on October 7, 2015: contributor
    I would like to merge #6747 first as it will make all soft fork deployments easier to review. I’d be happy to rebase this PR to #6747 myself. Otherwise ACK.
  60. petertodd commented at 12:47 pm on October 7, 2015: contributor

    I’m not sure that #6747 is safe to be honest… It moves a lot of code around in ways that aren’t obviously correct. (by the standards of consensus critical code that is)

    To review this pull-req, I’d suggest you follow the instructions in the commit message and verify that it’s identical to the BIP66 pull-req; if you find any issues the BIP66 soft-fork would be similarly vulnerable.

    On 7 October 2015 14:15:10 CEST, Eric Lombrozo notifications@github.com wrote:

    I would like to merge #6747 first as it will make all soft fork deployments easier to review. I’d be happy to rebase this PR to #6747 myself. Otherwise ACK.


    Reply to this email directly or view it on GitHub: #6351 (comment)

  61. btcdrak commented at 12:50 pm on October 7, 2015: contributor

    I’m not sure that #6747 is safe to be honest… It moves a lot of code around in ways that aren’t obviously correct. (by the standards of consensus critical code that is)

    I checked consensus is maintained in #6747 by doing a full blockchain sync from the network on top of careful code review, but I’m not agreeing or disagreeing that #6747 needs to be part of this ISM roll-out.

  62. petertodd commented at 12:52 pm on October 7, 2015: contributor

    @brcdrak Glad to hear! But again, its a big change… Anyway, I wrote the CLTV enable pull-req the way I did to make it maximally easy to review - if BIP66 was done right, this pull-req is done right.

    On 7 October 2015 14:50:54 CEST, “฿tcDrak” notifications@github.com wrote:

    I’m not sure that #6747 is safe to be honest… It moves a lot of code around in ways that aren’t obviously correct. (by the standards of consensus critical code that is)

    I checked consensus is maintained in #6747 by doing a full blockchain sync from the network on top of careful code review.


    Reply to this email directly or view it on GitHub: #6351 (comment)

  63. sipa commented at 12:52 pm on October 7, 2015: member
    btcdrak: that’s a necessary condition, but by no means a sufficient one. It also has to reject everything the old code rejected.
  64. dcousens commented at 12:57 pm on October 7, 2015: contributor

    It also has to reject everything the old code rejected.

    How would that be tested?

  65. petertodd commented at 1:03 pm on October 7, 2015: contributor
    @dcousens With great difficulty…. That’s one of the biggest challenges in changing consensus critical code.
  66. CodeShark commented at 2:59 pm on October 7, 2015: contributor

    @petertodd I created a new PR #6774 and rebased #6747 atop it to make the relevant code changes as explicit as possible.I also added the mechanism for your PR to it without activating it yet so that we’re ready to go with BIP65.

    In any case, I don’t want this to hold up deploying BIP65 and I understand you patterned it after BIP66. My intention was to make it even easier to compare the two (or any other soft fork deployments we make in the future, for that matter).

    Consensus-critical code does indeed present challenges, but I hope the relatively few code movements in these PRs are very simple to follow, now. Checking its correctness should basically amount to ensuring there were no copy/paste errors.

    I ran the comparison tool locally and it passed. It also passed Travis’ barrage of tests.

  67. Add CHECKLOCKTIMEVERIFY (BIP65) soft-fork logic
    Based on the earlier BIP66 soft-fork logic implemented by Pieter
    Wuille's 5a47811da5158df763aa2fca09ce646ee0c51e7b
    287f54fc90
  68. Add RPC tests for the CHECKLOCKTIMEVERIFY (BIP65) soft-fork
    bip65-cltv.py is based on the earlier BIP66 soft-fork RPC test
    implemented by Pieter Wuille's 819bcf9b9902319176cdb1d476cacfee9b3727ec
    
    bip65-cltv-p2p.py is based on the earlier BIP66 P2P test by Suhas
    Daftuar's d76412b068d95454732aa3def95decf35251759a
    cde7ab2d4e
  69. petertodd force-pushed on Oct 8, 2015
  70. Add BIP65 to getblockchaininfo softforks list 65ef372302
  71. petertodd force-pushed on Oct 8, 2015
  72. petertodd commented at 3:38 pm on October 8, 2015: contributor
    Rebased and added BIP65 to getblockchaininfo softforks list.
  73. CodeShark commented at 2:03 am on October 9, 2015: contributor

    @petertodd I created a branch demonstrating how we will deploy soft forks using #6747. The deployment logic for BIP65 can be conveniently compared side-by-side with that for BIP66, and future soft forks will also be possible to compare in this fashion regardless of whether we use IsSuperMajority or versionbits.

    grep for “DEPLOY BIP65” to see the the hooks.

  74. btcdrak commented at 8:45 pm on October 22, 2015: contributor
    ACK
  75. laanwj merged this on Oct 23, 2015
  76. laanwj closed this on Oct 23, 2015

  77. laanwj referenced this in commit 2a1090d4f5 on Oct 23, 2015
  78. NicolasDorier referenced this in commit 55a820dd5c on Oct 24, 2015
  79. NicolasDorier commented at 9:43 am on October 24, 2015: contributor

    By making my test, I noticed something odd…

    0// Now that we know we're comparing apples-to-apples, the
    1// comparison is a simple numeric one.
    2if(nLockTime > (long)txTo.LockTime)
    3    return false;
    

    This means that if nLockTime == txTo.LockTime, then the script evaluate to true, which made me believe that I can spend “1000 OP_CLTV” from exactly block 1000.

    However, such a transaction would not be final as IsFinalTx show :

    0    if ((int64_t)tx.nLockTime < ((int64_t)tx.nLockTime < LOCKTIME_THRESHOLD ? (int64_t)nBlockHeight : nBlockTime))
    1        return true;
    

    We can see that if such transaction is propagated at block 1000 it will be rejected as NonFinal ! This mean that 1000 OP_CLTV can only be spent from block 1001, even if the script pass at block 1000.

    Is this the expected behavior ? This seems kind of wierd… I would have changed to

    0// Now that we know we're comparing apples-to-apples, the
    1// comparison is a simple numeric one.
    2if(nLockTime > (long)txTo.LockTime - 1)
    3    return false;
    

    So the script “1000 OP_CLTV” only pass from block 1001.

  80. jl2012 commented at 3:42 pm on October 24, 2015: contributor

    @NicolasDorier

    So the script “1000 OP_CLTV” only pass from block 1001.

    It is consistent with the meaning of nLockTime, i.e. a tx is final only after (not at or before) the nLockTime. “1000 OP_CLTV” means the output is spendable after block 1000.

    1000 OP_CLTV can only be spent from block 1001, even if the script pass at block 1000.

    It is always possible to create a valid script at block X, but is not final at block X. For example if the current height is 380000, a script of “390000 OP_CLTV” with nLockTime = 391000 is still valid but not final

  81. NicolasDorier commented at 5:25 pm on October 24, 2015: contributor

    It is consistent with the meaning of nLockTime, i.e. a tx is final only after (not at or before) the nLockTime. “1000 OP_CLTV” means the output is spendable after block 1000.

    This is what is not consistent ! “1000 OP_CLTV” is currently true if nLockTime is 1000. (1000 included)

    Whereas a nLocktime of 1000 at block 1000 is not final as you rightly said " tx is final only after (not at or before)"

    A consistent behavior would be “1000 OP_CLTV” false with a nLockTime of 1000.

  82. jl2012 commented at 5:37 pm on October 24, 2015: contributor

    A consistent behavior would be “1000 OP_CLTV” false with a nLockTime of 1000.

    In that case you need a nLockTime of 1001 to spend “1000 OP_CLTV”, which means unspendable until block 1002.

    Anyway, by “consistent” I mean:

    1. With “X OP_CLTV”, an output is spendable after block X.
    2. With nLockTime = X, the tx is valid after block X
  83. NicolasDorier commented at 4:28 am on October 25, 2015: contributor
    1. With “X OP_CLTV”, an output is spendable after block X.

    No, with “X OP_CLTV” the output is spendable AT block X.

    1. With nLockTime = X, the tx is valid after block X

    Yes, in other words nLockTime=X the tx is valid at block X+1.

    This is the inconsistency. Because of 2., it means that X OP_CLTV is spendable at X+1 even if the script returns true at X. This is what is not very coherent.

  84. gmaxwell commented at 4:59 am on October 25, 2015: contributor
    @NicolasDorier it sounds like you are misunderstanding the design of OP_CLTV. There is no “return true” in it. It is a VERIFY op_code. It checks that the nlocktime field in the transaction agrees with the value on the stack, if it does– it does nothing. If it does not, it terminates execution. It has no clue about the height of the blockchain, and if it did it would make script execution no long a pure function of the transaction, violate the layering between transactions and the blockchain, make it possible for a script to become invalid that was valid before, etc.
  85. NicolasDorier commented at 6:44 am on October 25, 2015: contributor

    @gmaxwell I understand that. What I am saying is that from a script perpective “X OP_CLTV” means “can spend AT and AFTER block X”.

    While nLockTime=X means “can broadcast AT and AFTER block X+1”.

    Both of these means that “X OP_CLTV” will always been able to me spent at X+1, even if the X OP_CLTV will pass with nLockTime of X.

    Well, I don’t mind though, if it is the expected behavior, I have nothing to complain, sounds weird for me but this seems to be just a personal perspective rather than a mistake in the code. So I’m fine with it. I was just worried it was a mistake.

  86. gmaxwell commented at 6:57 am on October 25, 2015: contributor
    @NicolasDorier CLTV has nothing to do with blocks, X OP_CLTV means is “this transaction is invalid if X > the transaction’s nLocktime field”. What effect the nlocktime field has is largely a mystery to OP_CLTV.
  87. NicolasDorier commented at 4:24 pm on October 25, 2015: contributor

    Ok now by thinking about it like you said, If I want to say “Can spend this output at block X” then I need to use : “X-1 OP_CTLV” and at least nLockTime = X-1 when spending which is coherent.

    I was indeed making things more complicated than they needed to be, I’m fine now !

  88. petertodd commented at 5:36 pm on October 25, 2015: contributor

    Great!

    If you think there’s a way to better explain CLTV in the BIP, pull-reqs welcome.

    On 25 October 2015 12:24:41 GMT-04:00, Nicolas Dorier notifications@github.com wrote:

    Ok now by thinking about it like you said,
    If I want to say “Can spend this output at block X” then I need to use

    “X-1 OP_CTLV” and at least nLockTime = X-1 when spending which is coherent indeed.

    I was indeed making things more complicated than they needed to be, I’m fine now !


    Reply to this email directly or view it on GitHub: #6351 (comment)

  89. bokobza referenced this in commit be7c307a26 on Nov 5, 2017
  90. 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-11-17 06:12 UTC

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