Repository navigation
Conversation
Deliberately apply the standard transaction sigop limit during consensus accounting to test whether existing coverage detects undercounting a non-standard P2SH transaction.
Add a block-level P2SH sigop test using a single transaction above the consensus limit.
This reverts commit 0175450a6ae5dc2dd5e8770492d46ca183fcbedd.
Deliberately omit the P2SH contribution from transactions carrying witness data to verify whether the test suite detects mixed sigop undercounting.
Ensure a witness transaction counts its P2SH sigops.
sedited
added a commit
to bitcoin/bitcoin
that referenced
this pull request
Sep 7, 2026
d180b89 test: add mixed P2SH/witness sigop accounting (Lőrinc) 6e60c36 test: add P2SH sigop counting coverage (Musa Haruna) Pull request description: Add test coverage for sigop counting in P2SH spends in `test_witness_sigops()`, addressing the existing TODO. The new cases mirror the existing P2WSH sigop tests by constructing transactions that: - remain below the block sigop limit (accepted), - exceed the limit (rejected with bad-blk-sigops) Since P2SH sigops are accounted as legacy sigops, the expected sigop cost accounts for the 4× legacy weighting applied during consensus validation. The added coverage verifies the enforcement of the block sigop limit for both witness and P2SH spends, including mixed P2SH/witness transactions. **Acknowledgement:** During review ([comment](#35164 (review))), **l0rinc** demonstrated, using mutation testing on his branch [here](l0rinc#248), that the original test suite would not detect two consensus sigop undercounting bugs. Those experiments helped validate the coverage added by this PR and motivated the inclusion of the mixed P2SH/witness regression test. ACKs for top commit: l0rinc: reACK d180b89 Bicaru20: ACK d180b89 sedited: ACK d180b89 Tree-SHA512: 795923f56316c3cad4d02a572ed6486a0f3f62bd524fb162d2bcd884108485974e96f38c08b5ff0a8659feecfc208c8d7e93dde2b9e0517c70f6343c2063d9b5
Kino1994
pushed a commit
to Kino1994/bitcoin-full-history
that referenced
this pull request
Sep 13, 2026
…witness_sigops d180b891a2904fb787ac5fa1ed66f56c98496698 test: add mixed P2SH/witness sigop accounting (Lőrinc) 6e60c362bc1e373a284911381e2a513f57f5f26b test: add P2SH sigop counting coverage (Musa Haruna) Pull request description: Add test coverage for sigop counting in P2SH spends in `test_witness_sigops()`, addressing the existing TODO. The new cases mirror the existing P2WSH sigop tests by constructing transactions that: - remain below the block sigop limit (accepted), - exceed the limit (rejected with bad-blk-sigops) Since P2SH sigops are accounted as legacy sigops, the expected sigop cost accounts for the 4× legacy weighting applied during consensus validation. The added coverage verifies the enforcement of the block sigop limit for both witness and P2SH spends, including mixed P2SH/witness transactions. **Acknowledgement:** During review ([comment](bitcoin/bitcoin#35164 (review))), **l0rinc** demonstrated, using mutation testing on his branch [here](l0rinc/bitcoin#248), that the original test suite would not detect two consensus sigop undercounting bugs. Those experiments helped validate the coverage added by this PR and motivated the inclusion of the mixed P2SH/witness regression test. ACKs for top commit: l0rinc: reACK d180b891a2904fb787ac5fa1ed66f56c98496698 Bicaru20: ACK d180b891a2904fb787ac5fa1ed66f56c98496698 sedited: ACK d180b891a2904fb787ac5fa1ed66f56c98496698 Tree-SHA512: 795923f56316c3cad4d02a572ed6486a0f3f62bd524fb162d2bcd884108485974e96f38c08b5ff0a8659feecfc208c8d7e93dde2b9e0517c70f6343c2063d9b5
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem: This draft PR demonstrates the coverage claim in this review comment on #35164.
Existing tests allow two deliberately introduced P2SH sigop undercounts to pass: capping the per-transaction count and skipping P2SH sigops in transactions that also contain witness data.
Fix: Each
FIXMEcommit introduces one undercount, the following test commit exposes it, and the next commit reverts it. The final tree contains only the two focused regression tests.