getblocktemplate fails for old clients after segwit activation #9841

issue jnewbery opened this issue on February 23, 2017
  1. jnewbery commented at 7:05 PM on February 23, 2017: member

    segwit.py is supposed to test that "non-segwit miners get a valid GBT response after the fork":

            print("Verify non-segwit miners get a valid GBT response after the fork")
            send_to_witness(1, self.nodes[0], find_unspent(self.nodes[0], 50), self.pubkey[0], False, Decimal("49.998"))
            try:
                tmpl = self.nodes[0].getblocktemplate({})
                assert(len(tmpl['transactions']) == 1)  # Doesn't include witness tx
                assert(tmpl['sigoplimit'] == 20000)
                assert(tmpl['transactions'][0]['hash'] == txid)
                assert(tmpl['transactions'][0]['sigops'] == 2)
                assert(('!segwit' in tmpl['rules']) or ('segwit' not in tmpl['rules']))
            except JSONRPCException:
                # This is an acceptable outcome
                pass
    

    in fact what happens is that bitcoind returns a "Support for 'segwit' rule requires explicit client support" error to the getblocktemplate RPC. We always catch that error in the except: block and continue the test. None of the asserts in the try: branch are ever tested.

    I don't know what the intent here is. I would expect non-segwit miners to continue to be able to use getblocktemplate after segwit activation. If that's true, then there's a bug in getblocktemplate(). If miners aren't supposed to be able use getblocktemplate() after segwit activation without setting the rules:['segwit'] option, then we should explicitly test that as follows:

            assert_raises_jsonrpc(-8, "Support for 'segwit' rule requires explicit client support", self.nodes[0].getblocktemplate, {})
    

    and remove all the test code that isn't being used.

  2. jnewbery commented at 7:05 PM on February 23, 2017: member
  3. jnewbery cross-referenced this on Feb 23, 2017 from issue Fix RPC failure testing (continuation of #9707) by jnewbery
  4. luke-jr commented at 10:10 PM on February 23, 2017: member

    It's possible to support GBT for non-segwit miners after segwit activates, but Core currently does not. The test passes so long as it isn't giving a broken result.

  5. jnewbery commented at 10:15 PM on February 23, 2017: member

    Makes sense. I'll remove the try branch. If Core does support GBT for non-segwit miners in future, a test case should be added as part of that PR.

  6. jnewbery cross-referenced this on Feb 23, 2017 from issue Fix segwit getblocktemplate test by jnewbery
  7. laanwj closed this on Mar 6, 2017

  8. bitcoin 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-20 06:55 UTC