5

I've seen the term sigop in many places frequently. I've tried to figure out what does it mean by searching, and found that it's abbreviation of signature operation. But it's still not clear to me the meaning. I guess every opcode of scriptSig is considered to be a sigop. Am I right?

I would appreciate any explanation.

Edit:

I think this question is completely different than this. My question is clearly about what is the sigop, while the other question is about calculation of sigops.

1

2 Answers 2

12

A sigop is script opcode which performs a signature check. That includes OP_CHECKSIG, OP_CHECKSIGVERIFY, OP_CHECKMULTISIG, and OP_CHECKMULTISIGVERIFY.

This concept matters because of a consensus rule in Bitcoin which limits the number of sigops per block. How they are counted depends on the context:

  • In the scriptPubKey of outputs, and in scriptSig of inputs (the latter happens ~never, but if it did, it would be counted):
    • OP_CHECKSIG and OP_CHECKSIGVERIFY count as 4
    • OP_CHECKMULTISIG and OP_CHECKMULTISIGVERIFY count as 80
  • In P2SH redeemscripts:
    • OP_CHECKSIG and OP_CHECKSIGVERIFY count as 4
    • OP_CHECKMULTISIG and OP_CHECKMULTISIGVERIFY count as 4n when preceded by OP_n, and as 80 otherwise.
  • In P2WSH witness scripts:
    • OP_CHECKSIG and OP_CHECKSIGVERIFY count as 1
    • OP_CHECKMULTISIG and OP_CHECKMULTISIGVERIFY count as n when preceded by OP_n, and as 20 otherwise.
  • In P2TR taproot scripts:
    • Sigops are not counted.

A valid block cannot have more than 80000 sigops (so roughly 1 per 50 bytes of block data), as counted by the rules above. Note that this is checked before actually executing any scripts. So it doesn't require these opcode to actually be executed (e.g. they also count sigops that are surrounded by OP_IF ... OP_ENDIF in unexecuted branches, or in coinbase scriptSigs which are never executed).

In taproot, a different mechanism is used. Instead of having a global per-block limit, there is a per-transaction-input limit, proportional to the size of that input. Also only actually executed checks for claimed-to-be-valid signatures are counted.

2
  • Thanks for your answer. Sigops count matter because they're expensive to execute? Am I right? Commented Feb 25, 2023 at 17:55
  • 2
    Yeah, they make it illegal for blocks to contain so many signature checking operations that the block would be excessively slow to validate. Commented Feb 25, 2023 at 19:25
3

To add to Pieter's answer:

The sigops limit and how sigops are counted changed with the activation of SegWit in 2017. The sigop count in pre-SegWit scripts (P2PK, P2PKH, ...) was quadrupled. The block limit was increased from 20000 to 80000. See the sigops section in BIP-141: https://github.com/bitcoin/bips/blob/master/bip-0141.mediawiki#sigops

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.