Review report

bitcoin/bitcoin: PR #36741

2 suggestions

Earlier concerns neither republished nor resolved: 1 suggestion. See the Run archive for their assessments.

Optional improvements

Link

[suggestion] · Negative-feerate rounding directions remain implicit

Explicit infinity directions would clarify the otherwise correct rounding comments for negative feerates, including the edge case changed by this PR.

Location: src/policy/feerate.h:59 (head).

Details and suggested fix

Removing the special case makes CFeeRate(-123).GetFee(8) return 0 rather than -1. “Rounds up” means toward positive infinity here, not away from zero. GetFeePerK instead rounds toward negative infinity: CFeeRate(CAmount{-1}, 3).GetFeePerK() returns -334, not the -333 obtained by truncating. Spell out those two directions in the header, matching FeeFrac::EvaluateFee. No current production caller passing a negative feerate to GetFee was found.


Link

[suggestion] · Exact CFeeRate fuzz comparison excludes representable boundary cases

The inherited /1000 guards skip valid boundary inputs even though the earlier representability check already makes the CFeeRate comparison safe when !round_down.

Location: src/test/fuzz/feefrac.cpp:228 (head).

Details and suggested fix

For mul64 = INT64_MAX, mul32 = div = 1 and round_down = false, quot_abs is INT64_MAX, so the bailout passes but the /1000 guards skip the CFeeRate comparison. With mul32 >= 0, the constructor preserves (mul64, div) and GetFee delegates to EvaluateFeeUp; in the !round_down branch, res and the representability check already use that same direction. Compare CFeeRate(mul64, div).GetFee(mul32) directly with res in that branch without these guards, retaining the guarded comparison for round_down samples, where a representable floor does not guarantee a representable ceiling. This broadens the wrapper assertion to the full representable ceiling domain; FeeFrac's arithmetic already has full-range checks.


Coverage details

Earlier concerns

Earlier reports raised these, with the titles and severities shown there. This review neither republished nor resolved them.