Bury bip9 deployments #12360

pull jnewbery wants to merge 4 commits into bitcoin:master from jnewbery:bury_bip9_deployments changing 17 files +186 −249
  1. jnewbery commented at 5:23 pm on February 5, 2018: member

    This hardcodes CSV and segwit activation heights, similar to the BIP 90 buried deployments for BIPs 34, 65 and 66.

    Both CSV and segwit have been active for over 8 months. Hardcoding the activation height is a code simplification, makes it easier to understand segwit activation status, and reduces technical debt.

  2. jtimon commented at 5:33 pm on February 5, 2018: contributor
    This will need rebase after #11739 , won’t it?
  3. jnewbery commented at 6:08 pm on February 5, 2018: member

    This will need rebase after #11739 , won’t it?

    There are no dependencies between the two, but you’re correct that there are some minor conflicts in the implementations. I’m happy to rebase if 11739 is merged first.

  4. in src/rpc/blockchain.cpp:1085 in fc50434d31 outdated
    1105-    rv.push_back(Pair("id", name));
    1106-    rv.push_back(Pair("version", version));
    1107-    rv.push_back(Pair("reject", SoftForkMajorityDesc(version, pindex, consensusParams)));
    1108-    return rv;
    1109+    rv.pushKV("type", "buried");
    1110+    rv.pushKV("type", "buried");
    


    sipa commented at 9:59 pm on February 5, 2018:
    Duplicated line?

    promag commented at 10:01 pm on February 5, 2018:
    Yes? :trollface:

    jnewbery commented at 10:21 pm on February 5, 2018:
    Fixed
  5. in src/chainparams.cpp:62 in b58d5603c0 outdated
    58@@ -59,6 +59,11 @@ void CChainParams::UpdateVersionBitsParameters(Consensus::DeploymentPos d, int64
    59     consensus.vDeployments[d].nTimeout = nTimeout;
    60 }
    61 
    62+void CChainParams::UpdateSegwitHeight(const int& height)
    


    promag commented at 10:04 pm on February 5, 2018:
    Any good reason for reference?

    jnewbery commented at 10:21 pm on February 5, 2018:
    None. Removed.
  6. jnewbery force-pushed on Feb 5, 2018
  7. laanwj added the label Validation on Feb 6, 2018
  8. laanwj added the label Consensus on Feb 6, 2018
  9. in src/consensus/params.h:61 in caab009d91 outdated
    55@@ -58,6 +56,10 @@ struct Params {
    56     int BIP65Height;
    57     /** Block height at which BIP66 becomes active */
    58     int BIP66Height;
    59+    /** Block height at which CSV becomes active */
    60+    int CSVHeight;
    61+    /** Block height at which Segwit becomes active */
    


    Empact commented at 9:04 pm on February 8, 2018:
    Is it helpful to continue referencing the BIP numbers in these comments? I would guess so.

    jnewbery commented at 9:27 pm on February 8, 2018:
    Sure. Comments added.

    dcousens commented at 12:54 pm on February 12, 2018:
    Why not refer to the BIP numbers solely instead of alternating?

    MarcoFalke commented at 12:56 pm on February 12, 2018:
    the segwit deployment covered more than one bip
  10. jnewbery force-pushed on Feb 8, 2018
  11. in src/rpc/blockchain.cpp:1087 in 32cbe4828d outdated
    1107-    rv.push_back(Pair("reject", SoftForkMajorityDesc(version, pindex, consensusParams)));
    1108-    return rv;
    1109+    rv.pushKV("type", "buried");
    1110+    // getblockchaininfo reports the softfork as active from when the chain height is
    1111+    // one below the activation height
    1112+    rv.push_back(Pair("active", chainActive.Tip()->nHeight + 1 >= height));
    


    jamesob commented at 12:57 pm on February 12, 2018:
    Nit: any reason this isn’t just rv.pushKV("active", ...); for consistency?

    jnewbery commented at 1:52 pm on February 12, 2018:
    Requires #12193

    jnewbery commented at 4:14 pm on February 12, 2018:
    ah. It’s just been merged. Will rebase.
  12. in src/rpc/blockchain.cpp:1161 in 32cbe4828d outdated
    1169-            "        \"reject\": {             (object) progress toward rejecting pre-softfork blocks\n"
    1170-            "           \"status\": xx,        (boolean) true if threshold reached\n"
    1171+            "  \"chainwork\": \"xxxx\"     (string) total amount of work in active chain, in hexadecimal\n"
    1172+            "  \"pruned\": xx,             (boolean) if the blocks are subject to pruning\n"
    1173+            "  \"pruneheight\": xxxxxx,    (numeric) lowest-height complete block stored\n"
    1174+            "  \"softforks\": {               (object) status of softforks\n"
    


    jamesob commented at 1:08 pm on February 12, 2018:
    We don’t seem to have any testing for the contents of this key - is this the case? Happy to either write some for this PR or file a follow-up.

    jnewbery commented at 1:54 pm on February 12, 2018:
    You’re right. rpc_blockchain.py should be updated. If you’re happy to contribute a commit to add tests, I can include it in this PR.
  13. in src/rpc/blockchain.cpp:1187 in 32cbe4828d outdated
    1154@@ -1160,36 +1155,28 @@ UniValue getblockchaininfo(const JSONRPCRequest& request)
    1155             "  \"difficulty\": xxxxxx,         (numeric) the current difficulty\n"
    1156             "  \"mediantime\": xxxxxx,         (numeric) median time for the current best block\n"
    1157             "  \"verificationprogress\": xxxx, (numeric) estimate of verification progress [0..1]\n"
    1158-            "  \"initialblockdownload\": xxxx, (bool) (debug information) estimate of whether this node is in Initial Block Download mode.\n"
    


    jamesob commented at 1:15 pm on February 12, 2018:

    Curious why removal of this key and others (e.g. size_on_disk) is bundled with this changeset. Seems like RPC interface changes should be handled separately.

    Edit: looks like these were just removed from the help message; still probably don’t want to do that in this changeset, no?


    jnewbery commented at 2:07 pm on February 12, 2018:
    Oops. Bad rebase. Should be fixed now.
  14. jnewbery force-pushed on Feb 12, 2018
  15. jnewbery force-pushed on Feb 13, 2018
  16. jnewbery commented at 4:10 pm on February 13, 2018: member

    Rebased now that #12193 has been merged.

    ACK @jamesob’s 0be1f9d8a6bb2b8c47d6816b46d6764aee3cc06e commit.

  17. jamesob force-pushed on Feb 13, 2018
  18. jnewbery force-pushed on Feb 13, 2018
  19. jtimon commented at 8:08 pm on February 14, 2018: contributor
    utACK 0be1f9d8a6bb2b8c47d6816b46d6764aee3cc06e
  20. jnewbery force-pushed on Mar 7, 2018
  21. jnewbery commented at 6:43 pm on March 7, 2018: member
    rebased
  22. jamesob force-pushed on Mar 8, 2018
  23. jamesob commented at 3:36 pm on March 8, 2018: member
    Rebased.
  24. jnewbery force-pushed on Mar 19, 2018
  25. jnewbery commented at 1:31 pm on March 19, 2018: member
    Rebased
  26. in src/init.cpp:1172 in fc32e68ad2 outdated
    1158@@ -1158,6 +1159,21 @@ bool AppInitParameterInteraction()
    1159             }
    1160         }
    1161     }
    1162+
    


    jtimon commented at 6:08 pm on March 19, 2018:
    This can be done directly in CRegtestParams’s constructor, that way, the function UpdateSegwitHeight would not be needed.

    jnewbery commented at 6:38 pm on March 19, 2018:

    Seems like a good idea, but segwit height is also updated in one of the unit tests:

    https://github.com/bitcoin/bitcoin/pull/12360/files#diff-d5ba361c5f8be78eb4cc0c787c1fc78eR118

    I think we need the UpdateSegwitHeight() function call there.


    jtimon commented at 8:44 pm on March 19, 2018:
    I guess we still need UpdateSegwitHeight() then, or perhaps we can pass the other args (instead of g_args, or rather g_args plus “-segwitheight=432”) to SelectParams in https://github.com/bitcoin/bitcoin/pull/12360/files#diff-d5ba361c5f8be78eb4cc0c787c1fc78eR54 ? I guess not all BasicTestingSetup want 432 there…

    jnewbery commented at 8:50 pm on March 19, 2018:
    I think I’ll leave it as is for now. It may be possible to tidy this up in a future commit.
  27. jtimon changes_requested
  28. jnewbery force-pushed on Mar 27, 2018
  29. jnewbery commented at 1:35 pm on March 27, 2018: member
    Rebased
  30. jnewbery force-pushed on Mar 29, 2018
  31. jnewbery commented at 2:56 pm on March 29, 2018: member
    rebased
  32. jnewbery force-pushed on Apr 19, 2018
  33. jnewbery commented at 9:05 pm on April 19, 2018: member
    #11739 is merged. Rebased
  34. jnewbery force-pushed on Apr 20, 2018
  35. MarcoFalke commented at 0:03 am on April 22, 2018: member
    Tend to NACK. Just because buried deployments can be done safely doesn’t mean they should be done for the sole purpose of code refactoring without substantial motivation, advantages or simplifications. Since this is refactoring consensus code and also changing the consensus rules, I think a writeup on the motivation and tradeoffs is required. Note that none of the statements of the motivation given in BIP90 are applicable here, so I doubt that the overall gain (if any) is worth the time spent on this (code/discussions/formal writeups/review/…). I’d rather keep the deployments as versionbits deployments and instead treat IsWitnessEnabled as true for modules that don’t need to know when the witness commitment started to be a requirement for blocks containing witness transactions. I’d guess compact block relay qualifies for this, since it only relays recent blocks. Alternatively the “mining” code, which only makes sense to call on chains where IsWitnessEnabled is already true.
  36. MarcoFalke commented at 2:12 pm on April 22, 2018: member
    Potentially also the mempool, after which #12124 could be rebased and reopened.
  37. jnewbery commented at 10:48 pm on April 22, 2018: member

    @MarcoFalke - I disagree. Once a softfork is deployed and is sufficiently buried, the activation mechanism is purely academic. Removing complexity and improving the simplicity of the code is motivation enough.

    I think a writeup on the motivation and tradeoffs is required

    Yes - I intend to send a writeup to the mailing list if this PR is merged.

    As a meta-point, although review and feedback is always welcome, concept NACKs are much more useful early after a PR has been opened. This PR is a rebase of #11398, which was opened 7 months ago and has now been rebased ~10 times (including once requested by you). This PR and its antecedent have already been ACKed or concept ACKed by 5 contributors. If your objection is time spent on discussion/review, then that ship has already sailed :)

  38. jnewbery force-pushed on Apr 23, 2018
  39. MarcoFalke commented at 5:15 pm on May 9, 2018: member

    Removing complexity and improving the simplicity of the code is motivation enough.

    I am not aware of any plans to get rid of the concept of versionbits-deployments, so the “simplifications and improvements” of the code are limited to that module of the code and don’t have beneficial side-effects or simplifications (such as BIP-90).

    I am not saying that the changes can not be made, but rather that there is no need to to them right now. It is good to keep this patch in mind and there is no harm in having it in a rebased form… My Concept NACK is more a -0.

    Please add some minimal motivation to the opening comment, if you plan to keep on curating this pull. I’d assume for new developers those changes to the consensus code are hard to follow in the absence of any motivation and the presence of merely a blob of code.

  40. jnewbery commented at 7:23 pm on May 9, 2018: member
    rebased
  41. jnewbery force-pushed on May 9, 2018
  42. in src/init.cpp:1182 in ec50d2bc41 outdated
    1158+        int64_t height = gArgs.GetArg("-segwitheight", chainparams.GetConsensus().SegwitHeight);
    1159+        if (height < -1 || height >= std::numeric_limits<int>::max()) {
    1160+            return InitError(strprintf("Activation height %ld for segwit is out of valid range. Use -1 to disable segwit.", height));
    1161+        }
    1162+        else if (height == -1) {
    1163+            LogPrintf("Segwit disabled for testing\n");
    


    MarcoFalke commented at 10:04 pm on May 9, 2018:
    It seems odd to add code just for the tests, that has no application outside of regtest. I’d prefer if the code paths in the tests that test segwit can be disabled are just removed. Afterward this code block and all other dead code (IsScriptWitnessEnabled, …) can be discarded.

    jnewbery commented at 6:31 pm on May 21, 2018:

    I completely agree. The only reason the ‘Segwit disabled’ code here and elsewhere exists is for p2p_segwit.py, where it’s used to test whether GBT doesn’t return a default witness commitment if segwit is disabled. That’s completely circular - we’re adding behaviour into the product so we can test whether that behaviour exists.

    I’d like to completely overhaul p2p_segwit.py and remove this special casing, but in a future PR. This PR is simply maintaining the existing functionality of setting -vbparams=segwit:0:0.

  43. sdaftuar commented at 2:50 pm on May 10, 2018: member

    In my view, segwit activation at some height is the consensus that the software assumes – given that our own wallet now generates segwit transactions by default it would be internally inconsistent to tolerate being on a chain on which segwit might never be active. Moreover, we’re contemplating merging a change in #13120 that would change the mempool logic to always accept segwit transactions, even if we were on a chain on which segwit was not active.

    I do agree with @MarcoFalke’s comment that this is not a necessary change; however I think it is still a desirable one – a height check seems simpler than VersionBits-based logic, even if making that change touches a bunch of code. For instance, future code readers interested in segwit logic should not have to wonder under what circumstances the VersionBits calls might not return THRESHOLD_ACTIVE. Further, I think replacing the VB logic with a height check also more accurate captures the uncertainty around the activation, where it was unclear whether segwit activated according to the rules specified in BIP 141, BIP 91, or BIP 148 (or something else?). Maintaining the software’s BIP 141 activation logic is an unnecessary and somewhat arbitrary burden, even if so far it has been a light one.

    I am not aware of any plans to get rid of the concept of versionbits-deployments, so the “simplifications and improvements” of the code are limited to that module of the code and don’t have beneficial side-effects or simplifications (such as BIP-90).

    I disagree with the second half that sentence – I think that the circumstances around whether segwit is or might be active do concern other parts of the code (such as the wallet, mempool, and mining, which must make choices around what transactions to generate, accept or select) and therefore it’s easier to reason about the possibilities if we remove chain-specific calculations and replace them with the height checks proposed here.

    In summary, I think replacing the activation logic with a height check makes the code more internally consistent and simpler to understand and reason about, so I think this is worth doing. Concept ACK.

  44. in test/functional/feature_segwit.py:44 in ec50d2bc41 outdated
    41@@ -42,9 +42,9 @@ def set_test_params(self):
    42         self.setup_clean_chain = True
    43         self.num_nodes = 3
    44         # This test tests SegWit both pre and post-activation, so use the normal BIP9 activation.
    


    MarcoFalke commented at 6:24 pm on May 10, 2018:
    Comment needs update to remove “BIP9”?

    jnewbery commented at 6:38 pm on May 21, 2018:
    fixed (here and in p2p_segwit.py).
  45. jnewbery force-pushed on May 21, 2018
  46. jnewbery commented at 6:39 pm on May 21, 2018: member
    Fixed @MarcoFalke’s comment and tidied up p2p_segwit.py a little.
  47. MarcoFalke added the label Needs rebase on Jun 6, 2018
  48. jnewbery force-pushed on Jun 6, 2018
  49. jnewbery commented at 4:26 pm on June 6, 2018: member
    rebased
  50. MarcoFalke removed the label Needs rebase on Jun 6, 2018
  51. MarcoFalke commented at 5:11 pm on June 6, 2018: member
    Could the rpc changes potentially be split up into a separate pull request, to not distract from the consensus changes?
  52. jnewbery commented at 5:43 pm on June 6, 2018: member

    Could the rpc changes potentially be split up into a separate pull request, to not distract from the consensus changes?

    It’s possible, but this PR already has two ACKs and a Concept ACK. I think that splitting it up would be generating more work for reviewers.

  53. [rpc] Tidy up reporting of buried and ongoing softforks
    This combines reporting of buried (formally ISM) softfork deployments
    and BIP9 versionbits softfork deployments into one JSON object in the
    getblockchaininfo return object.
    
    It also removes the redundant feature_bip9_softforks.py.
    feature_bip9_sofforks.py was intended to be a generic test for versionbits
    deployments. However, it only tests CSV activation and was not updated
    to test segwit activation. CSV activation is tested by
    feature_csv_activation.py, so this test is duplicated effort.
    5160abf189
  54. [Consensus] Bury CSV deployment height
    Hard code CSV deployment height to 419328 for mainnet.
    c2029c2cc3
  55. jnewbery force-pushed on Jun 12, 2018
  56. jnewbery commented at 4:06 pm on June 12, 2018: member
    rebased
  57. MarcoFalke commented at 4:50 pm on June 12, 2018: member

    It’s possible, but this PR already has two ACKs and a Concept ACK. I think that splitting it up would be generating more work for reviewers.

    The ACK are outdated and would need to be re-ACKed on the new commits anyway.

  58. [Consensus] Bury segwit deployment
    Hardcode segwit deployment height to 481824 for mainnet.
    ff98898042
  59. [tests] Add coverage for the content of getblockchaininfo.softforks ab740a0476
  60. jnewbery force-pushed on Jun 12, 2018
  61. jnewbery commented at 8:07 pm on June 12, 2018: member
    Fixed failing p2p_segwit.py
  62. jnewbery commented at 7:20 pm on June 14, 2018: member

    This is a revamped version of @jl2012’s #11398, which had concept ACKs from @gmaxwell @dcousens and @sdaftuar . This PR also has ACKs from @jamesob and @jtimon .

    Are people still interested in this? I haven’t had any feedback for the last three rebases (except @MarcoFalke’s NACKs), and I’d rather not continue rebasing if people have cooled on this idea.

  63. DrahtBot added the label Needs rebase on Jul 7, 2018
  64. DrahtBot commented at 8:45 am on July 7, 2018: member
  65. jnewbery commented at 2:42 pm on July 9, 2018: member
    Closing - 6 concept ACKs but no review so I guess this isn’t worth rebasing.
  66. jnewbery closed this on Jul 9, 2018

  67. MarcoFalke referenced this in commit 1bf2ff2bf8 on Aug 15, 2019
  68. laanwj removed the label Needs rebase on Oct 24, 2019
  69. DrahtBot locked this on Dec 16, 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-07-03 10:13 UTC

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