Great Consensus Cleanup Revival

Posted by ajtowns

Feb 6, 2025/02:19 UTC

In the realm of cryptocurrency programming, particularly within Bitcoin's scripting system, a nuanced discussion emerges regarding the classification and limitation of signature operations (sigops). A distinction is proposed to clarify and categorize sigops more efficiently. The term "sigop" remains designated for signatures found in pay-to-script-hash (P2SH), pay-to-witness-script-hash (P2WSH), and output script public keys. Meanwhile, it is suggested that a new term, potentially "sigchecked" or "legacysig," be introduced to refer to a different limit pertaining to new conditions.

The criteria for counting the number of sigops in a CheckMultisig (CMS) scenario is highlighted as a point of complexity. Specifically, if the number of keys is 16 or fewer, the count of sigops is equivalent to the number of keys. However, if the structure deviates from this—such as in scripts not directly invoking CMS with an OP_1 through OP_16 command but includes it after operations like addition or in configurations not strictly related to the key count—the sigop count defaults to 20. Examples provided illustrate this rule: a script adding two values before calling CMS results in a 20 sigop count, divergent from an intuitive count of 2 based on direct key numbers. Similarly, a script performing a CHECKMULTISIG operation without any keys effectively counts as 20 sigops instead of zero.

Moreover, the treatment of conditional checks within scripts adds another layer of complexity to sigop counting. Unexecuted branches within a script that contain signature checking operations, such as CHECKSIG, are accounted for in the total sigop count. For instance, a script structured with an IF CHECKSIG ELSE CHECKSIG ENDIF construction is considered to have 2 sigops, despite the sequential execution possibly only engaging one CHECKSIG operation. Conversely, a script that concludes with a CHECKSIG following an IF ELSE ENDIF structure is counted as having a single sigop, illustrating the nuanced approach required in accurately assessing sigop limitations within varied script contexts.

Link to Raw Post

Thread Summary (84 replies)

Mar 24 - Apr 21, 2025

Bitcoin Logo

TLDR

Join Our Newsletter

We’ll email you summaries of the latest discussions from authoritative bitcoin sources, like bitcoin-dev, lightning-dev, and Delving Bitcoin.

Explore all Products

ChatBTC imageBitcoin searchBitcoin TranscriptsSaving SatoshiBitcoin Transcripts Review
Built with 🧡 by the Bitcoin Dev Project
View our public visitor count

We'd love to hear your feedback on this project?

Give Feedback