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
  1. brunoerg commented at 3:10 PM on July 1, 2025: contributor

    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.

  2. test: check P2SH sigop count for coinbase tx d6aaffcb11
  3. DrahtBot added the label Tests on Jul 1, 2025
  4. 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.

    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-->

  5. theStack approved
  6. 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 GetP2SHSigOpCount is changed (or removed), whereas unit tests fail with this PR.

  7. ishaanam commented at 7:44 PM on July 1, 2025: contributor

    ACK d6aaffcb11adcf47480fcc5081af9dcb732decf3

  8. bitcoin deleted a comment on Jul 2, 2025
  9. 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

  10. 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

  11. 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).

  12. fanquake merged this on Jul 3, 2025
  13. fanquake closed this on Jul 3, 2025

  14. fanquake referenced this in commit 222fbfcc6a on Jul 3, 2025
  15. fanquake commented at 11:17 AM on July 3, 2025: member

    Backported to 29.x in #32863.

  16. l0rinc commented at 11:32 AM on July 3, 2025: contributor

    post-merge crACK

  17. brunoerg deleted the branch on Jul 3, 2025
  18. glozow referenced this in commit ef380a454c on Jul 18, 2025
  19. stringintech referenced this in commit f19e7819e9 on Jul 19, 2025
  20. alexanderwiederin referenced this in commit 9997c3d993 on Jul 25, 2025
  21. alexanderwiederin referenced this in commit 8d6ebb9c4e on Jul 28, 2025
  22. alexanderwiederin referenced this in commit 533a4585b5 on Jul 28, 2025
  23. yuvicc referenced this in commit 22f55cf11d on Aug 26, 2025
  24. ajtowns referenced this in commit 42ac1ad577 on Sep 4, 2025
  25. bug-castercv502 referenced this in commit d4bd8a1259 on Sep 28, 2025
  26. stickies-v referenced this in commit a19c56cd7c on Nov 4, 2025
  27. morozow referenced this in commit 62dd191b75 on May 8, 2026
  28. morozow referenced this in commit 8214c3bc7c on May 8, 2026
  29. Kino1994 referenced this in commit 26f3ec3ba4 on Jun 28, 2026
  30. BigcoinBGC referenced this in commit 8da31e74b3 on Jun 30, 2026
  31. bitcoin locked this on Jul 30, 2026

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-08-06 19:52 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me