Consensus: Remove ISM #8391

pull NicolasDorier wants to merge 1 commits into bitcoin:master from NicolasDorier:remove-ism changing 7 files +83 −107
  1. NicolasDorier commented at 11:40 PM on July 21, 2016: contributor

    I hard coded ISM SF in regtest and adapted the tests. Will try a sync on mainnet and testnet soon.

    Note that even if the activation threshold (75% which enforce a rule for block version above a number) and enforcement threshold (95% reject old versions) are different, only the enforcement one really matter post fork.

  2. in src/main.cpp:None in 8d4ca9ae28 outdated
    2375 |      }
    2376 |  
    2377 |      // Start enforcing CHECKLOCKTIMEVERIFY, (BIP65) for block.nVersion=4
    2378 |      // blocks, when 75% of the network has upgraded:
    2379 | -    if (block.nVersion >= 4 && IsSuperMajority(4, pindex->pprev, chainparams.GetConsensus().nMajorityEnforceBlockUpgrade, chainparams.GetConsensus())) {
    2380 | +    if (block.nVersion >= 4 && pindex->nHeight >= chainparams.GetConsensus().BIP65Height) {
    


    NicolasDorier commented at 11:45 PM on July 21, 2016:

    actually, I don't need to compare the version. BIP65Height represent the 95% threshold height, so the first condition is always true.

  3. NicolasDorier force-pushed on Jul 22, 2016
  4. MarcoFalke added the label Consensus on Jul 22, 2016
  5. in src/rpc/blockchain.cpp:None in 86f5e2e8e1 outdated
     829 |      {
     830 | -        if (pstart->nVersion >= minVersion)
     831 | -            ++nFound;
     832 | -        pstart = pstart->pprev;
     833 | +        case 2:
     834 | +            activated = consensusParams.BIP34Height >= pindex->nHeight;
    


    laanwj commented at 12:36 PM on July 22, 2016:

    Shouldn't this comparison be the other way around?

  6. NicolasDorier force-pushed on Jul 22, 2016
  7. NicolasDorier commented at 12:51 PM on July 22, 2016: contributor
    • Fixed the inverted condition of activation of ISM soft fork in RPC
    • Fix outdated rpc documentation for getblockchaininfo
  8. NicolasDorier force-pushed on Jul 22, 2016
  9. NicolasDorier force-pushed on Jul 22, 2016
  10. in src/rpc/blockchain.cpp:None in 705d731ed8 outdated
     816 | @@ -817,22 +817,23 @@ UniValue verifychain(const UniValue& params, bool fHelp)
     817 |  }
     818 |  
     819 |  /** Implementation of IsSuperMajority with better feedback */
     820 | -static UniValue SoftForkMajorityDesc(int minVersion, CBlockIndex* pindex, int nRequired, const Consensus::Params& consensusParams)
     821 | +static UniValue SoftForkMajorityDesc(int minVersion, CBlockIndex* pindex, const Consensus::Params& consensusParams)
    


    instagibbs commented at 1:40 PM on July 22, 2016:

    "minVersion" is a bit confusing after this.


    NicolasDorier commented at 2:26 PM on July 22, 2016:

    What would be better ?


    instagibbs commented at 2:29 PM on July 22, 2016:

    "version", like the caller SoftForkDesc

  11. in src/chainparams.cpp:None in 705d731ed8 outdated
     249 | -        consensus.nMajorityRejectBlockOutdated = 950;
     250 | -        consensus.nMajorityWindow = 1000;
     251 | -        consensus.BIP34Height = -1; // BIP34 has not necessarily activated on regtest
     252 | +        consensus.BIP34Height = 100000000; // BIP34 has not necessarily activated on regtest
     253 |          consensus.BIP34Hash = uint256();
     254 | +        consensus.BIP65Height = 1351; // BIP65 activated on regtest
    


    instagibbs commented at 1:53 PM on July 22, 2016:

    seem like magic numbers without explanation


    NicolasDorier commented at 2:12 PM on July 22, 2016:

    I'll update the comment, this magic number is chosen such that bip65 tests in python extended tests pass.

  12. in src/main.cpp:None in 705d731ed8 outdated
    2366 | @@ -2372,15 +2367,13 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin
    2367 |  
    2368 |      unsigned int flags = fStrictPayToScriptHash ? SCRIPT_VERIFY_P2SH : SCRIPT_VERIFY_NONE;
    2369 |  
    2370 | -    // Start enforcing the DERSIG (BIP66) rules, for block.nVersion=3 blocks,
    2371 | -    // when 75% of the network has upgraded:
    2372 | -    if (block.nVersion >= 3 && IsSuperMajority(3, pindex->pprev, chainparams.GetConsensus().nMajorityEnforceBlockUpgrade, chainparams.GetConsensus())) {
    2373 | +    // Start enforcing the DERSIG (BIP66) rule
    2374 | +    if (pindex->nHeight >= chainparams.GetConsensus().BIP66Height) {
    


    instagibbs commented at 2:01 PM on July 22, 2016:

    nit: Any reason not to leave version check in? The fewer differences the better, imo. (clearly this isn't a HF, just asking)


    NicolasDorier commented at 2:15 PM on July 22, 2016:

    Yes, will later make refactoring for libconsensus easier because this does not depend on Block anymore. Moreover, it is impossible that block.nVersion to be below 3 at this point. I'm using the 95% threshold for this test (compared to the 75% of before), so if the block.nVersion were below 3 it would have been rejected before by https://github.com/bitcoin/bitcoin/pull/8391/files#diff-7ec3c68a81efff79b6ca22ac1f1eabbaR3516


    sipa commented at 2:27 PM on July 22, 2016:

    The IsSuperMajority call is slow.


    instagibbs commented at 2:30 PM on July 22, 2016:

    @sipa? Hm? I was just asking about nVersion check.

    That said, future refactoring purposes is good enough for me.


    jtimon commented at 2:54 PM on July 22, 2016:

    Yeah, as @NicolasDorier points out the block.nVersion check can be safely removed from here because blocks with invalid versions will be rejected in ContextualCheckBlockHeader.

  13. in src/chainparams.cpp:None in 705d731ed8 outdated
     170 | -        consensus.nMajorityRejectBlockOutdated = 75;
     171 | -        consensus.nMajorityWindow = 100;
     172 |          consensus.BIP34Height = 21111;
     173 |          consensus.BIP34Hash = uint256S("0x0000000023b3a96d3484e5abb3755c413e7d41500f8e2a5c3f0dd01299cd8ef8");
     174 | +        consensus.BIP65Height = 581885; // 00000000007f6655f22f98e72ed80d8b06dc761d5da09df0fa1dc4be4f861eb6
     175 | +        consensus.BIP66Height = 330776; // 000000002104c8c45e99a8853285a3b592602a3ccde2b832481da85e9e4ba182
    


    MarcoFalke commented at 2:03 PM on July 22, 2016:

    Why is it not possible to check the hash for main and test?


    instagibbs commented at 2:07 PM on July 22, 2016:

    Where would that be useful? The hash is only used as an exception to BIP30 rule at https://github.com/bitcoin/bitcoin/blob/master/src/main.cpp#L2358


    jtimon commented at 3:21 PM on July 22, 2016:

    Well, in fact, what that's doing is that if we're past BIP34Height but at BIP34Height we don't have the hardcoded block, then keep checking bip30 as if bip34 hadn't been activated. But now in https://github.com/bitcoin/bitcoin/pull/8391/files#diff-7ec3c68a81efff79b6ca22ac1f1eabbaL3550 if we have a reorg below BIP34Height, BIP34 will be activated after BIP34Height regardless of the original activation being different, thus the optimization of not checking BIP30 if BIP34 is activated could be used as well. So BIP34Hash can go after this change, I believe. If we have a reorg to BIP34Height things are terribly broken anyway.

  14. in src/rpc/blockchain.cpp:None in 705d731ed8 outdated
     896 | @@ -897,13 +897,9 @@ UniValue getblockchaininfo(const UniValue& params, bool fHelp)
     897 |              "     {\n"
     898 |              "        \"id\": \"xxxx\",        (string) name of softfork\n"
     899 |              "        \"version\": xx,         (numeric) block version\n"
     900 | -            "        \"enforce\": {           (object) progress toward enforcing the softfork rules for new-version blocks\n"
     901 | +            "        \"reject\": {            (object) progress toward rejecting pre-softfork blocks (same fields as \"enforce\")\n"
    


    instagibbs commented at 2:04 PM on July 22, 2016:

    This comment doesn't really make sense to me since "enforce" is no longer anywhere.

  15. in src/chainparams.cpp:None in 705d731ed8 outdated
     244 | @@ -247,11 +245,10 @@ class CRegTestParams : public CChainParams {
     245 |      CRegTestParams() {
     246 |          strNetworkID = "regtest";
     247 |          consensus.nSubsidyHalvingInterval = 150;
     248 | -        consensus.nMajorityEnforceBlockUpgrade = 750;
     249 | -        consensus.nMajorityRejectBlockOutdated = 950;
     250 | -        consensus.nMajorityWindow = 1000;
     251 | -        consensus.BIP34Height = -1; // BIP34 has not necessarily activated on regtest
     252 | +        consensus.BIP34Height = 100000000; // BIP34 has not necessarily activated on regtest
    


    MarcoFalke commented at 2:05 PM on July 22, 2016:

    Why is this diff necessary?


    NicolasDorier commented at 4:06 PM on July 22, 2016:

    @MarcoFalke I just re added it because without, tests with block v1 on regnet get rejected by the "obsolete version" (https://travis-ci.org/bitcoin/bitcoin/jobs/146661777).

    It makes sense as if BIP34Height is -1 then https://github.com/bitcoin/bitcoin/pull/8391/files#diff-7ec3c68a81efff79b6ca22ac1f1eabbaR3515 will kick out.

  16. NicolasDorier force-pushed on Jul 22, 2016
  17. NicolasDorier force-pushed on Jul 22, 2016
  18. in src/consensus/params.h:None in 316ecbd469 outdated
      44 | -    int nMajorityRejectBlockOutdated;
      45 | -    int nMajorityWindow;
      46 |      /** Block height and hash at which BIP34 becomes active */
      47 |      int BIP34Height;
      48 |      uint256 BIP34Hash;
      49 | +    /** Block height at which BIP65 becomes active */
    


    jtimon commented at 2:50 PM on July 22, 2016:

    We can make an array with an enum, like with vDeployments. Say, vPastDeployments, vOldDeployments, vBuriedDeployments, or something of the sort.


    NicolasDorier commented at 3:00 PM on July 22, 2016:

    I prefer keeping change of logic and refactoring done in different PR. I want this PR to be easy to review, so I'm using the previous way of doing with BIP34Height.


    jtimon commented at 3:08 PM on July 22, 2016:

    Well, you can leave BIP34 as it is and put the new things in the array if you think that is less disruptive, no? Anyway, if you feel strongly against doing it now, we can do it later. It's just feel cleaner not to put code to destroy it "right afterwards" (I can foresee the same "we can do the refactor later" argument when moving BIP113 there...).

  19. jtimon commented at 3:22 PM on July 22, 2016: contributor

    utACK besides nits.

  20. Consensus: Remove ISM 122786d0e0
  21. NicolasDorier force-pushed on Jul 22, 2016
  22. NicolasDorier commented at 4:12 PM on July 22, 2016: contributor
  23. NicolasDorier commented at 1:49 AM on July 23, 2016: contributor

    Sync of Testnet succeed, the Travis error is unrelated to this PR is it possible to run it again ? (still going on for mainnet)

  24. NicolasDorier commented at 4:34 AM on July 26, 2016: contributor

    Intial sync of testnet and mainnet succeed.

  25. jtimon commented at 4:19 PM on July 26, 2016: contributor

    Here are my proposed changes in code: https://github.com/jtimon/bitcoin/compare/remove-ism...consensus-post-remove-ism

    In any case, utACK 122786d

  26. sipa commented at 7:42 PM on July 28, 2016: member

    Note that #8418 adds a means to override the activation times for BIP9 activations in regtest mode. Perhaps a compatible approach can be followed here? Or is there no need for testing with different softforks activate in regtest?

  27. sipa commented at 11:21 PM on July 31, 2016: member

    utACK 122786d0e0170c73536360b705af711e1338adbf

  28. NicolasDorier commented at 11:57 PM on July 31, 2016: contributor

    I'll do a separate PR on top of this one for using the approach of #8418 alongs with @jtimon suggestion. I prefer keeping this PR as simple as I can.

    EDIT: something like https://github.com/NicolasDorier/bitcoin/commit/e4844f776a5048cf7f10c0ec326e9a1ad73cb39f

  29. laanwj commented at 10:21 AM on August 4, 2016: member

    ACK 122786d

  30. laanwj merged this on Aug 4, 2016
  31. laanwj closed this on Aug 4, 2016

  32. laanwj referenced this in commit 37d83bb0a9 on Aug 4, 2016
  33. sdaftuar commented at 3:15 PM on August 4, 2016: member

    @morcos and I were discussing this, and I think this change is subtle enough that it deserves some kind of BIP write-up.

    Technically this change is a hardfork: old ISM-based code, when presented with an alternate chain history in which one of these softforks activated earlier, would then reject a subsequent block that violated the softfork before the hardcoded heights here, whereas this code would not reject such a block (since the softfork would not yet be enforced). This seems like a fundamental consequence of removing the ISM code (excluding doing something like checkpointing the whole headers chain to detect this kind of thing, which seems like obvious overkill).

    In my judgement this is fine, as by the time we deploy this code in 0.14, it'll have been over a year since the most recent one of these softforks deployed. But to further everyone's understanding of how these kinds of consensus changes are made (especially for future developers, as well as authors of alternate implementations) I think it'd be beneficial to document this change along with the considerations and rationale that went into it.

  34. jtimon commented at 4:13 PM on August 4, 2016: contributor

    I agree a BIP makes sense.

  35. NicolasDorier commented at 8:42 PM on August 4, 2016: contributor

    will write BIP

  36. codablock referenced this in commit 7321bfdd6b on Jan 20, 2018
  37. andvgal referenced this in commit aacc413baf on Jan 6, 2019
  38. random-zebra referenced this in commit 87e3dcddef on Mar 18, 2020
  39. 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: 2026-05-02 18:15 UTC

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