script: Remove dead code from OP_CHECKMULTISIG #33977

pull vostrnad wants to merge 1 commits into bitcoin:master from vostrnad:checkmultisig-dead-code changing 1 files +0 −2
  1. vostrnad commented at 2:29 am on December 1, 2025: none

    The stack size check before the dummy element check in OP_CHECKMULTISIG is redundant. The stack is previously validated to have least i elements (where i is number of pubkeys + number of signatures + 3), and then i - 1 elements are popped off the stack, leaving at least one element still in.

    The redundant check was added in #3843 (commit 6380180821917c22ecfd89128ee60aae6f4cac33). There it’s easy to see why it’s redundant – it’s inserted into a code path where another popstack would previously follow.

    Note the missing code coverage: https://maflcko.github.io/b-c-cov/total.coverage/src/script/interpreter.cpp.gcov.html#L1200

  2. script: Remove dead code from OP_CHECKMULTISIG
    Removes a redundant stack size check from OP_CHECKMULTISIG that was added in #3843 (commit 6380180821917c22ecfd89128ee60aae6f4cac33).
    53ca0dc3cf
  3. DrahtBot added the label Consensus on Dec 1, 2025
  4. DrahtBot commented at 2:29 am on December 1, 2025: contributor

    The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

    Code Coverage & Benchmarks

    For details see: https://corecheck.dev/bitcoin/bitcoin/pulls/33977.

    Reviews

    See the guideline for information on the review process.

    Type Reviewers
    ACK l0rinc

    If your review is incorrectly listed, please copy-paste <!–meta-tag:bot-skip–> into the comment that the bot should ignore.

  5. l0rinc commented at 10:36 am on December 1, 2025: contributor

    Code review ACK 53ca0dc3cfdad8c9fd994c3758a477e319379db1

    The lines are safe to remove since they’re side-effect free and the mentioned extra element is included in the initial stack size validation while the cleanup loop stops before popping it. The comment above it likely doesn’t need updating since it’s seems to refer to the line below. The SCRIPT_ERR_INVALID_STACK_OPERATION script error is used elsewhere, so we don’t need to clean that up either.

  6. billymcbip commented at 2:17 pm on December 1, 2025: none
    I think it wouldn’t hurt to have an assert(!stack.empty()); instead, just in case the code above is ever refactored.
  7. vostrnad commented at 2:26 pm on December 1, 2025: none
    The script interpreter code is so thoroughly tested, so infrequently refactored, and any change to it reviewed with such extreme caution that I don’t think we need to bother with an assert, but I can add it if others think it’s a good idea.

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: 2025-12-01 21:13 UTC

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