Mining: Enforce that segwit option must be set in GBT #14811

pull jnewbery wants to merge 2 commits into bitcoin:master from jnewbery:remove_non_segwit_mining changing 11 files +39 −62
  1. jnewbery commented at 5:38 pm on November 26, 2018: member

    Calling getblocktemplate without the segwit rule specified is most likely a client error, since it results in lower fees for the miner. Prevent this client error by failing getblocktemplate if called without the segwit rule specified.

    Of the previous 1000 blocks (measured at block 551591 (hash 0x…173c811)), 991 included segwit transactions.

  2. gmaxwell commented at 5:50 pm on November 26, 2018: contributor
    Concept ACK
  3. MarcoFalke commented at 7:22 pm on November 26, 2018: member
    Looks like a nice cleanup, and it might encourage miners running mining hardware or mining software that can’t yet handle segwit transactions to upgrade. Though, I can’t evaluate how much of a hassle it would be for them, so I won’t review this conceptually.
  4. DrahtBot commented at 7:24 pm on November 26, 2018: member

    The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

    Conflicts

    Reviewers, this pull request conflicts with the following ones:

    • #14918 (RPCHelpMan: Check default values are given at compile-time by MarcoFalke)
    • #14459 (More RPC help description fixes by ch4ot1c)
    • #10595 (Bugfix: RPC/Mining: Use pre-segwit sigops and limits, when working with non-segwit GBT clients by luke-jr)

    If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

  5. practicalswift commented at 11:25 pm on November 26, 2018: contributor
    Concept ACK
  6. fanquake added the label Mining on Nov 26, 2018
  7. promag commented at 4:02 pm on November 27, 2018: member

    Is there a reason to not make it implicit and optionally return a warning?

    Otherwise could update getblocktemplate description to mention that template_request.rules is not optional, at least be {"rules":["segwit"]}?

  8. luke-jr commented at 4:21 pm on November 27, 2018: member
    The only time it wouldn’t be present is in the case of non-segwit miners. In that case, implying it would likely result in them producing invalid blocks.
  9. promag commented at 4:25 pm on November 27, 2018: member

    The only time it wouldn’t be present is in the case of non-segwit miners. In that case, implying it would likely result in them producing invalid blocks. @luke-jr required or implicit, they still/eventually have to update.

  10. luke-jr commented at 4:28 pm on November 27, 2018: member
    Yes, but it’s much nicer to have the miner give them an error immediately upon updating bitcoind, than find out weeks later that they’ve been wasting electricity mining invalid blocks.
  11. gmaxwell commented at 5:40 pm on November 27, 2018: contributor
    @promag Silently losing money (and mining invalid blocks!) is not an acceptable failure mode.
  12. Sjors commented at 6:20 pm on November 27, 2018: member
    Concept ACK after IRC discussion. Suggest adding a “Mining” section to the release notes to make this more visible to the small percentage of miners this may impact.
  13. jnewbery force-pushed on Nov 28, 2018
  14. jnewbery commented at 8:17 pm on November 28, 2018: member

    Suggest adding a “Mining” section to the release notes

    Done

  15. in doc/release-notes.md:73 in 62a4992a4a outdated
    64@@ -65,6 +65,13 @@ platform.
    65 Notable changes
    66 ===============
    67 
    68+Mining
    69+------
    70+
    71+- Calls to `getblocktemplate` will fail if the segwit rule is not specified.
    72+  Calling `getblocktemplate` without segwit specified is almost certainly
    73+  a misconfiguration since doing so results in lower fees for the miner.
    


    MarcoFalke commented at 8:24 pm on November 28, 2018:

    Lower fees sounds like a good thing.

    0  a misconfiguration since doing so results in lower rewards for the miner.
    

    jnewbery commented at 8:46 pm on November 28, 2018:
    updated
  16. jnewbery force-pushed on Nov 28, 2018
  17. MarcoFalke commented at 9:06 pm on November 29, 2018: member
    utACK 66c0f5bde1ba2c188933115337cf26a007d979be
  18. in doc/release-notes.md:192 in 66c0f5bde1 outdated
    188@@ -182,6 +189,8 @@ in the Low-level Changes section below.
    189   P2SH-P2WPKH, and P2SH-P2WSH. Requests for P2WSH and P2SH-P2WSH accept
    190   an additional `witnessscript` parameter.
    191 
    192+- See the *Mining* section for changes to `getblocktemplate`.
    


    promag commented at 11:15 pm on December 3, 2018:
    nit, use anchor: See the [Mining](#mining) ....

    jnewbery commented at 3:30 pm on December 4, 2018:
    Updated in the latest commit.
  19. in src/rpc/mining.cpp:533 in 66c0f5bde1 outdated
    528@@ -529,21 +529,17 @@ static UniValue getblocktemplate(const JSONRPCRequest& request)
    529     }
    530 
    531     const struct VBDeploymentInfo& segwit_info = VersionBitsDeploymentInfo[Consensus::DEPLOYMENT_SEGWIT];
    532-    // If the caller is indicating segwit support, then allow CreateNewBlock()
    533-    // to select witness transactions, after segwit activates (otherwise
    534-    // don't).
    535-    bool fSupportsSegwit = setClientRules.find(segwit_info.name) != setClientRules.end();
    536+    // GBT must be called with 'segwit' set in the rules
    537+    if (setClientRules.find(segwit_info.name) == setClientRules.end()) {
    


    promag commented at 11:17 pm on December 3, 2018:
    nit, count() instead of find()?

    jnewbery commented at 3:30 pm on December 4, 2018:
    thanks. Updated
  20. promag commented at 11:26 pm on December 3, 2018: member
    utACK 66c0f5b, just 2 nits for your consideration.
  21. jnewbery force-pushed on Dec 4, 2018
  22. jnewbery commented at 3:30 pm on December 4, 2018: member
    Thanks @promag . I’ve taken both of those nits.
  23. promag commented at 3:49 pm on December 4, 2018: member
    utACK 6c57746, no problem
  24. MarcoFalke commented at 4:25 pm on December 4, 2018: member
    re-utACK 6c577469c7
  25. [mining] segwit option must be set in GBT
    Calling getblocktemplate without the segwit rule specified is most
    likely a client error, since it results in lower fees for the miner.
    Prevent this client error by failing getblocktemplate if called without
    the segwit rule specified.
    0025c9eae4
  26. [docs] add release note for change to GBT
    GBT must now be called with the segwit rule.
    d2ce315fbf
  27. in src/rpc/mining.cpp:508 in 6c577469c7 outdated
    533-    // to select witness transactions, after segwit activates (otherwise
    534-    // don't).
    535-    bool fSupportsSegwit = setClientRules.find(segwit_info.name) != setClientRules.end();
    536+    // GBT must be called with 'segwit' set in the rules
    537+    if (setClientRules.count(segwit_info.name) != 1) {
    538+        throw JSONRPCError(RPC_INVALID_PARAMETER, "getblocktemplate must be called with the segwit rule set (call with {\"rules\": [\"segwit\"]})");
    


    MarcoFalke commented at 7:50 pm on December 5, 2018:
    I guess this needs rebase and then “optional” changed to “required”?

    jnewbery commented at 9:42 pm on December 10, 2018:
    done
  28. jnewbery force-pushed on Dec 10, 2018
  29. MarcoFalke commented at 9:49 pm on December 10, 2018: member
    re-utACK d2ce315fbf (Only change was rebase and making “rules” as well as “template_request” required arguments)
  30. Sjors commented at 1:06 pm on December 11, 2018: member
    tACK d2ce315
  31. MarcoFalke merged this on Dec 21, 2018
  32. MarcoFalke closed this on Dec 21, 2018

  33. MarcoFalke referenced this in commit feda41e0a7 on Dec 21, 2018
  34. domob1812 referenced this in commit bf7dae620c on Dec 24, 2018
  35. jnewbery deleted the branch on Jan 7, 2019
  36. 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-12-21 15:12 UTC

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