`getblocktemplate` returns a standard P2PKH with 0 sigops (testnet) #24255

issue antonilol opened this issue on February 3, 2022
  1. antonilol commented at 9:17 PM on February 3, 2022: none

    <!-- This issue tracker is only for technical issues related to Bitcoin Core. General bitcoin questions and/or support requests are best directed to the Bitcoin StackExchange at https://bitcoin.stackexchange.com. For reporting security issues, please read instructions at https://bitcoincore.org/en/contact/. If the node is "stuck" during sync or giving "block checksum mismatch" errors, please ensure your hardware is stable by running memtest and observe CPU temperature with a load-test tool such as linpack before creating an issue! -->

    i noticed a standard 0 sigops transaction when calling getblocktemplate, but that transaction turned out to be P2PKH of course with OP_CHECKSIG

    <!-- Describe the issue -->

    Expected behavior

    "sigops": 36, in block template json

    <!--- What behavior did you expect? -->

    Actual behavior

          ...
          "txid": "54eee291ec73fcc3faf496cf90ffc9b6faa57940234802bdae58c51540016853",
          "hash": "54eee291ec73fcc3faf496cf90ffc9b6faa57940234802bdae58c51540016853",
          "depends": [
          ],
          "fee": 1404,
          "sigops": 0,   <-- here
          "weight": 5472
          ...
    

    <!--- What was the actual behavior (provide screenshots if the issue is GUI-related)? -->

    To reproduce

    <!--- How reliably can you reproduce the issue, what are the steps to do so? -->

    somehow get the sigop count of 54eee291ec73fcc3faf496cf90ffc9b6faa57940234802bdae58c51540016853 (testnet)

    System information

    bitcoin.org binary v22.0.0

    <!-- What version of Bitcoin Core are you using, where did you get it (website, self-compiled, etc)? -->

    <!-- What type of machine are you observing the error on (OS/CPU and disk type)? -->

    <!-- GUI-related issue? What is your operating system and its version? If Linux, what is your desktop environment and graphical shell? -->

    <!-- Any extra information that might be useful in the debugging process. -->

    <!--- This is normally the contents of a `debug.log` or `config.log` file. Raw text or a link to a pastebin type site are preferred. -->

  2. antonilol added the label Bug on Feb 3, 2022
  3. pinheadmz commented at 10:11 PM on March 18, 2023: member

    It's not unusual for a transaction to have 0 block-limit sigops.

    The tx in your example has 9 inputs which all spend from legacy p2pkh UTXOs. In each of those spends, the OP_CHECKSIG is literally in the output of the previous transaction, and the sigop cost was "paid for" by the funding transactions. The inputs only contain public keys and signatures (no sigops). The single output of that tx is a P2WPKH. The signature operation required to spend that output will be "paid for" by the spending transaction: https://github.com/bitcoin/bips/blob/master/bip-0141.mediawiki#user-content-Sigops

    I ran getblocktemplate from my mainnet node and it built a block with 83 0-sigop transactions:

    $ bitcoin/src/bitcoin-cli getblocktemplate '{"rules":["segwit"]}' | grep -e  '"sigops": 0' | wc -l
    83
    

    ... most of these are P2TR transactions like https://blockstream.info/tx/0b3caca257f483715bccf70274179f78d8043a88b65df07f295dba40fe0a89f0?expand and in BIP342 it is documented that these sigops do not count towards the block limit at all: https://github.com/bitcoin/bips/blob/master/bip-0342.mediawiki#resource-limits

  4. antonilol closed this on Mar 19, 2023

  5. bitcoin locked this on Mar 18, 2024
Contributors
Labels

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-04-13 15:14 UTC

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