AI-generated analysisPublished automatically and not human-verified. Validated context appears in community notes below.
← Watch feed
Low 48 Bitcoin

revert #4838 and #4847 using div_ceil

Public commit record

What the developer wrote

Authored by Andrew Poelstra

76/100 · Adequate
revert #4838 and #4847 using div_ceil

In #4838 we used saturating addition to simulate `div_ceil`, which gives
incorrect results on extreme values but at least doesn't panic. Similar
in the followup PR #4847. (These aren't detected by clippy, but I remember
them.)
✓ Descriptive subject✓ Names a concrete action or component✓ Provides detailed explanatory context✓ Links an issue, advisory, or supporting reference
The short version

What changed, and why it matters

This commit fixes a subtle arithmetic bug in how Bitcoin fee rates and transaction weights are rounded up. The previous code tried to avoid crashes on extremely large numbers by using 'saturating addition,' but that produced slightly wrong rounded-up results for the maximum possible values. The patch replaces that workaround with Rust's proper div_ceil function, which gives the mathematically correct ceiling division even at the extremes. In practice, this mostly affects edge-case calculations with maximum values and is unlikely to be directly exploitable for theft, but it removes a source of incorrect fee/weight estimates.

Recommended action

Review any downstream code that relies on to_sat_per_kwu_ceil, to_sat_per_vb_ceil, to_sat_per_kvb_ceil, Weight::to_kwu_ceil, or Weight::to_vbytes_ceil with maximum or near-maximum inputs. Update to this commit or a later release to ensure correct rounding. Consider adding property-based tests for u64 boundary values in these conversion functions.

Security signals we found

01

Incorrect ceiling division on extreme values due to saturating_add clamping

02

Reversion of prior defensive fix (#4838/#4847) that traded correctness for panic avoidance

03

Unit tests updated to assert corrected max-value behavior

04

No explicit security advisory or CVE referenced in commit

Risk score

Why this scored 48/100

Our methodology →
Potential impact 12/30
Exploitability 8/25
Stealth signal 7/15
Affected reach 10/15
Confidence 7/10
Evidence quality 4/5
Human-validated context

Community notes

Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.

No validated notes yet.

The AI analysis stands alone for now. Submit a note if you can add evidence or important context.