Relax IsStandard rules for pay-to-script-hash transactions #4365

pull gavinandresen wants to merge 1 commits into bitcoin:master from gavinandresen:relax_isstandard changing 3 files +97 −66
  1. gavinandresen commented at 12:56 pm on June 18, 2014: contributor

    Relax the AreInputsStandard() tests for P2SH transactions – allow any Script in a P2SH transaction to be relayed/mined, as long as it has 15 or fewer signature operations.

    Rationale: https://gist.github.com/gavinandresen/88be40c141bc67acb247

    I don’t have an easy way to test this, but the code changes are straightforward and I’ve updated the AreInputsStandard unit tests.

  2. ghost commented at 6:08 pm on June 18, 2014: none
    ACK
  3. in src/main.cpp: in f4a78bebc4 outdated
    638-            nArgsExpected += tmpExpected;
    639+            if (Solver(subscript, whichType2, vSolutions2))
    640+            {
    641+                int tmpExpected;
    642+                if (whichType2 == TX_SCRIPTHASH)  // HASH160 <hash> OP_EQUAL
    643+                    tmpExpected = 1;
    


    laanwj commented at 2:01 pm on June 19, 2014:
    Is this special-case just to make things explicit? I checked and ScriptSigArgsExpected returns 1 for TX_SCRIPTHASH.
  4. mikehearn commented at 6:14 pm on June 19, 2014: contributor

    I worry that this will have the same effect as the fee drop - users and merchants will upgrade, miners won’t, and the resulting lack of mempool consensus makes double spending easier. When we did the fee drop we didn’t worry about this much because we’d done it before and it worked out OK, but this time seems to be different and miners aren’t bothering to upgrade, perhaps because 0.9 had nothing for them.

    I don’t want to make things unnecessarily complicated, but I wonder if the change should be marked in the coinbase. Then IsStandard changes once a sufficient percentage of hashing power has upgraded. Alternatively maybe if @dgenr8 gets his double spend relaying code in, that might also help.

  5. petertodd commented at 6:35 pm on June 19, 2014: contributor
    @mikehearn Are we going to hold up every feature just because it might impact zeroconf transactions? Eligius already has implemented this patch with ~10% of hashing power; if you’re worried about double-spends that opportunity already exists.
  6. in src/test/script_P2SH_tests.cpp: in f4a78bebc4 outdated
    299+    oneAndTwo << OP_1 << key[0].GetPubKey() << key[1].GetPubKey() << key[2].GetPubKey();
    300+    oneAndTwo << OP_3 << OP_CHECKMULTISIG;
    301+    oneAndTwo << OP_2 << key[3].GetPubKey() << key[4].GetPubKey() << key[5].GetPubKey();
    302+    oneAndTwo << OP_3 << OP_CHECKMULTISIG;
    303+    oneAndTwo << OP_AND;
    304+    keystore.AddCScript(oneAndTwo);
    


    petertodd commented at 1:20 pm on June 20, 2014:
    Pedantic: This example isn’t actually spendable. Right now the first CHECKMULTISIG will leave a ‘1’ on the stack making the second CHECKMULTISIG always fail. Change it to a CHECKMULTISIGVERIFY instead and remove the AND.
  7. petertodd commented at 1:21 pm on June 20, 2014: contributor

    ACK modulo CHECKMULTISIG nit.

    I had been working on my own version of this patch and came up with a pretty similar design. Tested this with real-world non-std P2SH transactions on mainnet, no issues found. I also can’t see any way that this could be a DoS issue - the ’limit sigops’ approach taken is exactly how my version worked as well.

  8. Relax IsStandard rules for pay-to-script-hash transactions
    Relax the AreInputsStandard() tests for P2SH transactions --
    allow any Script in a P2SH transaction to be relayed/mined,
    as long as it has 15 or fewer signature operations.
    
    Rationale: https://gist.github.com/gavinandresen/88be40c141bc67acb247
    
    I don't have an easy way to test this, but the code changes are
    straightforward and I've updated the AreInputsStandard unit tests.
    7f3b4e9569
  9. gavinandresen commented at 7:13 pm on June 23, 2014: contributor
    Nits picked (removed unneeded test @laanwj found, fixed the sigop-counting unit test so it uses a ‘realistic’ Script) and rebased for the CMutableTransaction change.
  10. BitcoinPullTester commented at 7:26 pm on June 23, 2014: none
    Automatic sanity-testing: PASSED, see http://jenkins.bluematt.me/pull-tester/p4365_7f3b4e95695d50a4970e6eb91faa956ab276f161/ for binaries and test log. This test script verifies pulls every time they are updated. It, however, dies sometimes and fails to test properly. If you are waiting on a test, please check timestamps to verify that the test.log is moving at http://jenkins.bluematt.me/pull-tester/current/ Contact BlueMatt on freenode if something looks broken.
  11. petertodd commented at 7:38 pm on June 23, 2014: contributor
    ACK
  12. mhanne commented at 9:14 am on June 24, 2014: contributor
    FYI, as @petertodd suggested, I added an index of the “inner” P2SH script types to bitcoin-ruby/webbtc, so you can see unusual p2sh scripts that are already spent: http://webbtc.com/p2sh_scripts/unknown
  13. gavinandresen referenced this in commit 6259937388 on Jun 27, 2014
  14. gavinandresen merged this on Jun 27, 2014
  15. gavinandresen closed this on Jun 27, 2014

  16. zauguin referenced this in commit 6cd198f380 on Dec 30, 2015
  17. luke-jr referenced this in commit 67cd666d30 on Feb 12, 2016
  18. lateminer referenced this in commit aab3e6a293 on Oct 25, 2018
  19. 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-18 03:12 UTC

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