[qa] Ensure we don't generate a too-big block in p2sh sigops test #16464

pull sdaftuar wants to merge 1 commits into bitcoin:master from sdaftuar:2019-07-fix-feature-block changing 1 files +8 −0
  1. sdaftuar commented at 6:45 PM on July 25, 2019: member

    There's a bug in the loop that is calculating the block size in the p2sh sigops test -- we start with the size of the block when it has no transactions, and then increment by the size of each transaction we add, without regard to the changing size of the encoding for the number of transactions in the block.

    This might be fine if the block construction were deterministic, but the first transaction in the block has an ECDSA signature which can be variable length, so we see intermittent failures of this test when the initial transaction has a 70-byte signature and the block ends up being one byte too big.

    Fix this by double-checking the block size after construction.

  2. [qa] Ensure we don't generate a too-big block in p2sh sigops test bf3be5297a
  3. sdaftuar commented at 6:46 PM on July 25, 2019: member

    @jonasschnelli I believe this explains the test failures you've seen.

  4. jonasschnelli commented at 6:52 PM on July 25, 2019: contributor

    Looks good. utACK bf3be5297a746982cf8e83f45d342121e5665f80

    For the record: I saw that feature_block.py failed (twice in the last days) on my custom CI while travis did not fail (https://bitcoinbuilds.org/index.php?job=2ff386f7-798c-4f9a-8233-dc62978cb175).

    Thanks @sdaftuar for tracking it down.

  5. jnewbery commented at 7:51 PM on July 25, 2019: member

    tested ACK bf3be5297a746982cf8e83f45d342121e5665f80

    Tested by applying this patch to master (fails) and this PR (passes):

    -- a/test/functional/feature_block.py
    +++ b/test/functional/feature_block.py
    @@ -467,6 +467,8 @@ class FullBlockTest(BitcoinTestFramework):
             tx = self.create_tx(spend, 0, 1, p2sh_script)
             tx.vout.append(CTxOut(spend.vout[0].nValue - 1, CScript([OP_TRUE])))
             self.sign_tx(tx, spend)
    +        while len(tx.vin[0].scriptSig) > 71:
    +            self.sign_tx(tx, spend)
             tx.rehash()
             b39 = self.update_block(39, [tx])
             b39_outputs += 1
    

    The patch grinds signatures until one of size <= 70 bytes is found, and the proceeds.

    I've done some analysis of signature sizes produced by our python ECDSA implementation (#15826) and the OpenSSL code that we used before. Both use low-s by default and do not use RFC6979. In both cases, 70 and 71 byte sigs occurred just under 50% of the time and 69 byte sigs occurred ~0.4% of the time (sizes exclude the SIGHASH byte). That means that without this fix, we'd expect the test to fail around 1/250 - 1/200 times.

  6. DrahtBot added the label Tests on Jul 25, 2019
  7. MarcoFalke merged this on Jul 28, 2019
  8. MarcoFalke closed this on Jul 28, 2019

  9. MarcoFalke referenced this in commit 3489b71512 on Jul 28, 2019
  10. sidhujag referenced this in commit eaf7a33e1b on Jul 29, 2019
  11. PastaPastaPasta referenced this in commit 052543dbe6 on Jun 27, 2021
  12. PastaPastaPasta referenced this in commit 77cd863e60 on Jun 28, 2021
  13. PastaPastaPasta referenced this in commit 282f74a24b on Jun 29, 2021
  14. PastaPastaPasta referenced this in commit ae6982c02d on Jul 1, 2021
  15. PastaPastaPasta referenced this in commit 64eb530ed3 on Jul 1, 2021
  16. PastaPastaPasta referenced this in commit f9cbe0502d on Jul 12, 2021
  17. PastaPastaPasta referenced this in commit 4a89dd584e on Sep 11, 2021
  18. PastaPastaPasta referenced this in commit 816be0fe70 on Sep 11, 2021
  19. MarcoFalke locked this on Dec 16, 2021

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-04-14 12:15 UTC

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