Return the script type from Solver #13429

pull Empact wants to merge 1 commits into bitcoin:master from Empact:solver-return changing 10 files +62 −98
  1. Empact commented at 5:28 am on June 11, 2018: member

    Because false is synonymous with TX_NONSTANDARD, this conveys the same information and makes the handling explicitly based on script type, simplifying each call site.

    Prior to this change it was common for the return value to be ignored, or for the return value and TX_NONSTANDARD to be redundantly handled.

  2. in src/policy/policy.cpp:77 in 24465c87bb outdated
    75@@ -76,7 +76,7 @@ bool IsStandard(const CScript& scriptPubKey, txnouttype& whichType, const bool w
    76     else if (!witnessEnabled && (whichType == TX_WITNESS_V0_KEYHASH || whichType == TX_WITNESS_V0_SCRIPTHASH))
    77         return false;
    78 
    79-    return whichType != TX_NONSTANDARD && whichType != TX_WITNESS_UNKNOWN;
    80+    return true;
    


    Empact commented at 5:29 am on June 11, 2018:
    Calling this out as a potential issue in the existing code - should this be a whitelist rather than a blacklist?
  3. Empact force-pushed on Jun 11, 2018
  4. Empact force-pushed on Jun 11, 2018
  5. kallewoof commented at 7:27 am on June 11, 2018: member
    Concept ACK. Code looks like a general improvement. (I wish we did less of foo(args, modifiedargs) stuff in general.)
  6. laanwj added the label Wallet on Jun 11, 2018
  7. laanwj added the label Refactoring on Jun 11, 2018
  8. DrahtBot added the label Needs rebase on Jun 12, 2018
  9. sipa commented at 5:03 pm on June 12, 2018: member
    Concept ACK
  10. Empact force-pushed on Jun 12, 2018
  11. Empact commented at 5:20 pm on June 12, 2018: member
    Rebased for #13120
  12. DrahtBot removed the label Needs rebase on Jun 12, 2018
  13. in src/script/standard.cpp:160 in 36709313d6 outdated
    164-        return false;
    165+    txnouttype whichType = Solver(scriptPubKey, vSolutions);
    166 
    167-    if (whichType == TX_PUBKEY)
    168-    {
    169+    if (whichType == TX_NONSTANDARD) {
    


    achow101 commented at 11:28 pm on June 12, 2018:
    nit: This if is unnecessary as TX_NONSTANDARD will return false anyways at the end of these if blocks.
  14. achow101 commented at 11:31 pm on June 12, 2018: member
    utACK 36709313d616de62b394c44d941a0d13fd6fd7f0
  15. Empact force-pushed on Jun 12, 2018
  16. Empact commented at 11:43 pm on June 12, 2018: member
    Removed unnecessary if noted by @achow101
  17. in src/policy/policy.cpp:73 in bdcde813bc outdated
    72@@ -73,7 +73,7 @@ bool IsStandard(const CScript& scriptPubKey, txnouttype& whichType)
    73                (!fAcceptDatacarrier || scriptPubKey.size() > nMaxDatacarrierBytes))
    


    promag commented at 0:11 am on June 13, 2018:
    Nit, add { }.

    Empact commented at 9:08 pm on June 13, 2018:
    Planning to leave that since I’m not touching the line otherwise
  18. promag commented at 0:18 am on June 13, 2018: member

    utACK bdcde81.

    I wonder if TX_NONSTANDARD should have a note that it must be 0 (which is the enum default) for when if (Solver(...)) is used?

  19. Empact commented at 9:08 pm on June 13, 2018: member
    @promag I don’t think that helps much, since, the only other bit of output is vSolutions, which can only be interpreted in light of the type, so in practice callers switch on the type.
  20. DrahtBot commented at 8:23 pm on June 14, 2018: member
    • #13525 (Report reason inputs are nonstandard from AreInputsStandard by Empact)

    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.

  21. sipa commented at 11:10 pm on June 14, 2018: member
    I’d prefer to get #13425 in first.
  22. Empact force-pushed on Jul 5, 2018
  23. Empact commented at 4:11 pm on July 5, 2018: member
    Rebased for #13120 and #13425
  24. laanwj commented at 4:27 pm on July 5, 2018: member
    utACK 4313e27d1fed1e8415cbfd98f34d6d1dac2432cf - I was also wondering about this
  25. Empact force-pushed on Jul 6, 2018
  26. Empact commented at 4:41 am on July 6, 2018: member
    On second look realized I had not previously removed the unnecessary if noted by @achow101. Removed that, and reviewed to check that there were no unexpected changes relative to 3670931.
  27. in src/policy/policy.cpp:77 in 7d26115d1b outdated
    74+               (!fAcceptDatacarrier || scriptPubKey.size() > nMaxDatacarrierBytes)) {
    75           return false;
    76+    }
    77 
    78-    return whichType != TX_NONSTANDARD && whichType != TX_WITNESS_UNKNOWN;
    79+    return true;
    


    Empact commented at 4:42 am on July 6, 2018:
    I’ll note again that this existing behavior makes me nervous. Should this be a whitelist?
  28. achow101 commented at 7:15 am on July 6, 2018: member
    re=utACK 7d26115d1b9d829a17f00b7045b990f460b7771d
  29. MarcoFalke removed the label Wallet on Jul 9, 2018
  30. MarcoFalke commented at 11:48 am on July 10, 2018: member
    utACK 7d26115d1b9d829a17f00b7045b990f460b7771d
  31. Empact force-pushed on Jul 19, 2018
  32. Empact commented at 5:06 am on July 19, 2018: member
    Rebased and updated for #13557
  33. DrahtBot added the label Needs rebase on Jul 22, 2018
  34. Return the script type from Solver
    Because false is synonymous with TX_NONSTANDARD, this conveys the same
    information and makes the handling explicitly based on script type,
    simplifying each call site.
    
    Prior to this change it was common for the return value to be ignored,
    or for the return value and TX_NONSTANDARD to be redundantly handled.
    984d72ec65
  35. Empact force-pushed on Jul 23, 2018
  36. Empact commented at 1:38 am on July 23, 2018: member
    Rebased for #13691
  37. DrahtBot removed the label Needs rebase on Jul 24, 2018
  38. laanwj commented at 3:38 pm on August 25, 2018: member
    re-utACK 984d72ec659361d8c1a6f3c6864e839a807817a7
  39. laanwj merged this on Aug 25, 2018
  40. laanwj closed this on Aug 25, 2018

  41. laanwj referenced this in commit 4cef8e0593 on Aug 25, 2018
  42. Empact deleted the branch on Oct 9, 2018
  43. deadalnix referenced this in commit bb2c97c5c3 on Jan 15, 2020
  44. jonspock referenced this in commit 348e4ff138 on Oct 6, 2020
  45. jonspock referenced this in commit a6ac24bb6a on Oct 10, 2020
  46. jonspock referenced this in commit f63daeb715 on Oct 10, 2020
  47. christiancfifi referenced this in commit ce16a964c6 on Aug 25, 2021
  48. christiancfifi referenced this in commit a444f07a0f on Aug 25, 2021
  49. christiancfifi referenced this in commit 8b68c99bfa on Aug 25, 2021
  50. christiancfifi referenced this in commit 916ab9d1ab on Aug 25, 2021
  51. christiancfifi referenced this in commit fe24095602 on Aug 25, 2021
  52. christiancfifi referenced this in commit b3f4ef00be on Aug 25, 2021
  53. Munkybooty referenced this in commit 4189f143f5 on Sep 8, 2021
  54. 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-10-04 22:12 UTC

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