We currently do not test that GetP2SHSigOpCount returns 0 for coinbase transactions (see line L129 at https://corecheck.dev/mutation/src/consensus/tx_verify.cpp). This PR addresses it.
test: check P2SH sigop count for coinbase tx #32850
pull brunoerg wants to merge 1 commits into bitcoin:master from brunoerg:2025-07-test-p2shsigopcount-coinbase changing 1 files +6 −0-
brunoerg commented at 3:10 PM on July 1, 2025: contributor
-
test: check P2SH sigop count for coinbase tx d6aaffcb11
- DrahtBot added the label Tests on Jul 1, 2025
-
DrahtBot commented at 3:10 PM on July 1, 2025: contributor
<!--e57a25ab6845829454e8d69fc972939a-->
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.
<!--006a51241073e994b41acfe9ec718e94-->
Code Coverage & Benchmarks
For details see: https://corecheck.dev/bitcoin/bitcoin/pulls/32850.
<!--021abf342d371248e50ceaed478a90ca-->
Reviews
See the guideline for information on the review process.
Type Reviewers ACK theStack, w0xlt, ishaanam, darosior, pablomartin4btc If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update.
<!--174a7506f384e20aa4161008e828411d-->
Conflicts
Reviewers, this pull request conflicts with the following ones:
- #29060 (Policy: Report reason inputs are non standard by ismaelsadeeq)
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.
<!--5faf32d7da4f0f540f40219e4f7537a3-->
- theStack approved
-
theStack commented at 5:25 PM on July 1, 2025: contributor
ACK d6aaffcb11adcf47480fcc5081af9dcb732decf3
Good catch. Verified that on master, indeed all unit and functional tests pass if the tested code part in
GetP2SHSigOpCountis changed (or removed), whereas unit tests fail with this PR. -
w0xlt commented at 6:42 PM on July 1, 2025: contributor
-
ishaanam commented at 7:44 PM on July 1, 2025: contributor
ACK d6aaffcb11adcf47480fcc5081af9dcb732decf3
- bitcoin deleted a comment on Jul 2, 2025
-
maflcko commented at 7:49 AM on July 2, 2025: member
the branch is dead code outside of tests, so it could also be removed/disabled. Though, it may be better to add a test than to refactor the consensus code here. So lgtm
-
darosior commented at 9:23 AM on July 2, 2025: member
Yeah, i think it's preferable to remove dead code than to test it:
diff --git a/src/consensus/tx_verify.cpp b/src/consensus/tx_verify.cpp index 95466b759cb..5036e26e21a 100644 --- a/src/consensus/tx_verify.cpp +++ b/src/consensus/tx_verify.cpp @@ -125,8 +125,7 @@ unsigned int GetLegacySigOpCount(const CTransaction& tx) unsigned int GetP2SHSigOpCount(const CTransaction& tx, const CCoinsViewCache& inputs) { - if (tx.IsCoinBase()) - return 0; + Assert(!tx.IsCoinBase()); unsigned int nSigOps = 0; for (unsigned int i = 0; i < tx.vin.size(); i++)(If you do this you might need to adapt fuzz targets.)
That said, i guess unit-tested dead consensus code is better than not-unit-tested dead consensus code. utACK d6aaffcb11adcf47480fcc5081af9dcb732decf3
-
pablomartin4btc commented at 11:41 PM on July 2, 2025: member
ACK d6aaffcb11adcf47480fcc5081af9dcb732decf3
(coinbase transactions don’t refer to a real previous output and thus cannot be spending P2SH outputs, making the sigop count irrelevant for them).
- fanquake merged this on Jul 3, 2025
- fanquake closed this on Jul 3, 2025
- fanquake referenced this in commit 222fbfcc6a on Jul 3, 2025
-
l0rinc commented at 11:32 AM on July 3, 2025: contributor
post-merge crACK
- brunoerg deleted the branch on Jul 3, 2025
- glozow referenced this in commit ef380a454c on Jul 18, 2025
- stringintech referenced this in commit f19e7819e9 on Jul 19, 2025
- alexanderwiederin referenced this in commit 9997c3d993 on Jul 25, 2025
- alexanderwiederin referenced this in commit 8d6ebb9c4e on Jul 28, 2025
- alexanderwiederin referenced this in commit 533a4585b5 on Jul 28, 2025
- yuvicc referenced this in commit 22f55cf11d on Aug 26, 2025
- ajtowns referenced this in commit 42ac1ad577 on Sep 4, 2025
- bug-castercv502 referenced this in commit d4bd8a1259 on Sep 28, 2025
- stickies-v referenced this in commit a19c56cd7c on Nov 4, 2025
- morozow referenced this in commit 62dd191b75 on May 8, 2026
- morozow referenced this in commit 8214c3bc7c on May 8, 2026
- Kino1994 referenced this in commit 26f3ec3ba4 on Jun 28, 2026
- BigcoinBGC referenced this in commit 8da31e74b3 on Jun 30, 2026
- bitcoin locked this on Jul 30, 2026