test: p2p block malleability #33172

pull musaHaruna wants to merge 1 commits into bitcoin:master from musaHaruna:test-p2p-block-malleability changing 1 files +31 −1
  1. musaHaruna commented at 3:45 pm on August 11, 2025: none

    This PR adds a functional test to repeat the existing malleability check for oversized coinbase witness nonce size using a block that is small enough to be relayed over the P2P network.

    This addresses the TODO in test_block_malleability by ensuring behavior is consistent between submitblock RPC and P2P relay.

  2. DrahtBot added the label Tests on Aug 11, 2025
  3. DrahtBot commented at 3:45 pm on August 11, 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/33172.

    Reviews

    See the guideline for information on the review process.

    Type Reviewers
    ACK maflcko, janb84
    Stale ACK bc1cindy

    If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update.

  4. musaHaruna force-pushed on Aug 11, 2025
  5. bc1cindy commented at 0:17 am on August 12, 2025: none

    ACK 19c5dba

    Tested on macOS, completed successfully in ~64 seconds.

    The implementation properly addresses the TODO comment by adding P2P test coverage for block malleability. Uses 100KB witness data - large enough to trigger bad-witness-nonce-size but small enough to stay under MAX_BLOCK_WEIGHT. Follows existing patterns and tests both rejection and acceptance paths consistently.

    Good addition to test coverage.

  6. janb84 commented at 11:48 am on August 12, 2025: contributor

    ACK 19c5dba8ca8ff66f3a8d4a62e2145c67e81e6a6f

    PR Replaces TODO with test code that tests a rejection of a P2P transmitted invalid block (as suggested by TODO).

    Test on master : ~63 sec , test with PR : ~63 sec no significant impact ✅

    Corecheck does not report any increase of test coverage with this change, but it does not have (much) impact on test duration. Seems somewhat preferable to test this scenario there for (weak) ACK.

    • code review ✅
    • build and tested ✅
    • good commit message ✅
  7. in test/functional/p2p_segwit.py:846 in 19c5dba8ca outdated
    841+        # same validation rejection but keeps the block under the weight limit
    842+        # so it can be sent via P2P.
    843+        relayable_block.vtx[0].wit.vtxinwit[0].scriptWitness.stack.append(b'a' * 100_000)
    844+
    845+        # Ensure it's relayable by weight
    846+        assert relayable_block.get_weight() <= MAX_BLOCK_WEIGHT
    


    brunoerg commented at 1:11 pm on August 14, 2025:
    19c5dba8ca8ff66f3a8d4a62e2145c67e81e6a6f: you could use assert_greater_than_or_equal.

    musaHaruna commented at 11:22 am on August 21, 2025:
    Added in the latest push. Thank you!
  8. test: repeat block malleability test with relayable block over P2P
    Adds a functional test that repeats the existing witness nonce size
    malleability check using a block under MAX_BLOCK_WEIGHT so it can be
    relayed over the P2P network, addressing the TODO in test_block_malleability.
    
    Includes rejection check for 'bad-witness-nonce-size' and confirmation
    that a corrected block is accepted.
    d0e1bbad01
  9. in test/functional/p2p_segwit.py:858 in 19c5dba8ca outdated
    853+        assert_not_equal(self.nodes[0].getbestblockhash(), relayable_block.hash_hex)
    854+
    855+        # Now fix the block by removing the extra witness data
    856+        relayable_block.vtx[0].wit.vtxinwit[0].scriptWitness.stack.pop()
    857+
    858+        # Confirm the block is still relayable
    


    zaidmstrr commented at 5:04 pm on August 19, 2025:
    nit: you can change this comment to Confirm the block is still relayable by weight, As this is not checking whether a block is relayable its just checking weight.

    musaHaruna commented at 11:22 am on August 21, 2025:
    Fixed as suggested in the latest push
  10. musaHaruna force-pushed on Aug 21, 2025
  11. maflcko commented at 6:43 am on August 29, 2025: member
    lgtm ACK d0e1bbad016cc4949094daea2934712f92dfeecd
  12. DrahtBot requested review from janb84 on Aug 29, 2025
  13. janb84 commented at 1:48 pm on August 29, 2025: contributor

    re ACK d0e1bbad016cc4949094daea2934712f92dfeecd

    Changes since last ACK;

    • small NIT suggested changes

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-09-02 06:12 UTC

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