Skip to content

test: clarify coinbase sigop accounting in GetTransactionSigOpCost#92

Draft
l0rinc wants to merge 3 commits intomasterfrom
l0rinc/test-coinbase-sigopcost
Draft

test: clarify coinbase sigop accounting in GetTransactionSigOpCost#92
l0rinc wants to merge 3 commits intomasterfrom
l0rinc/test-coinbase-sigopcost

Conversation

@l0rinc
Copy link
Copy Markdown
Owner

@l0rinc l0rinc commented Jan 12, 2026

This is a reimplementation of the abandoned bitcoin#32840.

Context

This PR makes the GetTransactionSigOpCost test coverage explicitly document (and guard) the coinbase special-case: coinbase transactions only contribute legacy sigops and skip P2SH and witness sigop accounting.

The existing GetTxSigOpCost test was monolithic and didn’t make the coinbase behavior obvious, which can lead to confusion (e.g. when reasoning about sigop budgets in mining/Stratum-related work) and makes regressions harder to spot.

Changes

  • Split GetTxSigOpCost into focused test cases so failures don’t mask other vectors.
  • Replace assert() with Boost checkers for clearer failure output.
  • Add explicit cases ensuring coinbase-shaped inputs do not count P2SH/witness sigops (and assert witness preconditions where relevant).

@l0rinc l0rinc changed the title test: clarify coinbase sigop accounting in GetTransactionSigOpCost test: clarify coinbase sigop accounting in GetTransactionSigOpCost Jan 12, 2026
l0rinc and others added 3 commits January 12, 2026 19:37
The previous monolithic test mixed several independent vectors, so the first failure would stop coverage of the remaining ones.

Split the vectors into focused test cases to make failures easier to diagnose and keep follow-up edits reviewable.

It's best to view this commit without whitespace changes.
`assert()` aborts the entire test run on the first failure, hiding which other vectors are broken and providing little context.

Switch these checks to Boost assertions and reuse a shared set of standard script verification flags.
`GetTransactionSigOpCost` treats coinbase transactions specially: they only contribute legacy sigops, skipping P2SH and witness accounting and avoiding input lookups.

Add explicit coverage for coinbase-shaped inputs in both witness and P2SH contexts, and assert the witness precondition so the intent stays clear.

Co-authored-by: Gary Krause <gary.krause@mara.com>
@l0rinc l0rinc force-pushed the l0rinc/test-coinbase-sigopcost branch from d46bc6a to be4e602 Compare January 12, 2026 18:37
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