Skip to content

test: demonstrate P2SH sigop coverage gaps - #248

Closed
l0rinc wants to merge 6 commits into
masterfrom
detached614
Closed

l0rinc wants to merge 6 commits into
masterfrom
detached614

Conversation

@l0rinc

@l0rinc l0rinc commented Jul 24, 2026 •

Copy link
Copy Markdown
Owner

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 FIXME commit 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.

l0rinc added 6 commits July 23, 2026 18:53
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.
@l0rinc l0rinc closed this Jul 24, 2026
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant