test: allow 3 bytes of fee overestimate in assert_fee_amount #36408

pull fametrano wants to merge 1 commits into bitcoin:master from fametrano:test-fee-tolerance-short-sig changing 1 files +3 −2
  1. fametrano commented at 6:53 AM on October 2, 2026: contributor

    The wallet sizes a transaction assuming a 71-byte low-R ECDSA signature. A signature whose r or s has leading zero bytes is shorter, so the fee can cover a few bytes more than the signed transaction needs. In #36394 the wallet estimated 219 bytes and paid 438 sat at 2 sat/vB, but the signed transaction was 216 bytes: the signature was 3 bytes short. That happens about once in 4 million signatures. assert_fee_amount allows only 2 bytes of overestimate, so the test failed.

    I raise the allowance to 3 bytes, which makes the failure about 200 times rarer. The check that the fee is not too low is unchanged. @maflcko suggested 3 bytes in #24151 and #25164.

    Fixes #36394.

    Made with my usual tools: a computer, the Internet and an LLM. The mistakes, as usual, are all mine.

  2. test: allow 3 bytes of fee overestimate in assert_fee_amount
    The wallet sizes a transaction assuming 71-byte low-R ECDSA signatures.
    A signature whose r or s has leading zero bytes is shorter, so the fee
    can cover a few bytes more than the signed transaction needs. A
    signature 3 bytes short (about 1 in 4 million) made wallet_send.py fail
    with an estimate of 219 bytes for a 216-byte transaction.
    
    Allowing 3 bytes instead of 2 makes this about 200 times rarer. The
    check that the fee is not too low is unchanged.
    
    Fixes #36394.
    050409b2c5
  3. DrahtBot added the label Tests on Oct 2, 2026
  4. DrahtBot commented at 6:53 AM on October 2, 2026: contributor

    <!--e57a25ab6845829454e8d69fc972939a-->

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

    <!--006a51241073e994b41acfe9ec718e94-->

    External sites

    <!--021abf342d371248e50ceaed478a90ca-->

    Reviews

    See the guideline and AI policy for information on the review process.

    Type Reviewers
    ACK Ayoazeez26

    If your review is incorrectly listed, please copy-paste <code>&lt;!--meta-tag:bot-skip--&gt;</code> into the comment that the bot should ignore.

    <!--5faf32d7da4f0f540f40219e4f7537a3-->

  5. Ayoazeez26 commented at 4:17 PM on October 4, 2026: none

    tACK 050409b2c5522eff0dc37c00a6d1225a8a437e17

    Tested on macOS with Python 3.14. wallet_send.py passes on this commit.

    I read through #36394 and the CI log there. Since running the test won't reproduce it (a 3-byte short signature is roughly 1 in 4 million), so I forced it instead by bumping the signature size in PKHDescriptor::MaxSatSize() from 71 to 74. That makes the wallet overestimate by 3 bytes on every run.

    On master with that change, wallet_send.py fails at the fee_rate=7 check:

    AssertionError: Fee of 0.00001554 BTC too high! (Should be 0.00001533 BTC)

    With 73 (+2) instead, the old check passes, as expected.

    With this PR and the same +3 change, all the assert_fee_amount checks pass. One more thing I noticed, with the +3 change, the run gets past all the fee checks but then fails in test_maxfeerate() with this error:

     test_framework.util.JSONRPCException: Fee rate exceeds maximum configured by user (maxfeerate) (-6)  [http_status=200]

    This is most likely from my +3 change but I thought it's worth noting.


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-10-08 23:51 UTC

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