Skip to content

fix(stdlib): use bigint arithmetic in GasFees.mul() for non-integer scalars#22383

Merged
PhilWindle merged 1 commit intomerge-train/spartanfrom
danielntmd/a-797-gasfees-mul-precision
Apr 9, 2026
Merged

fix(stdlib): use bigint arithmetic in GasFees.mul() for non-integer scalars#22383
PhilWindle merged 1 commit intomerge-train/spartanfrom
danielntmd/a-797-gasfees-mul-precision

Conversation

@danielntmd
Copy link
Copy Markdown
Contributor

GasFees.mul() converted bigint fee values to Number for non-integer scalar multiplication, silently losing precision for values above 2^53. Since gas fees are UInt128 and can exceed 2^53 under realistic conditions (e.g. when the fee asset depreciates relative to ETH), this produced incorrect fee calculations in wallet code that calls .mul(1.5).

Replaced the Number conversion with scaled bigint arithmetic that preserves full precision for all UInt128 values while maintaining the ceiling behavior needed for fee padding.

…calars

GasFees.mul() converted bigint fee values to Number for non-integer
scalar multiplication, silently losing precision for values above 2^53.
Since gas fees are UInt128 and can exceed 2^53 under realistic conditions
(e.g. when the fee asset depreciates relative to ETH), this produced
incorrect fee calculations in wallet code that calls .mul(1.5).

Replaced the Number conversion with scaled bigint arithmetic that
preserves full precision for all UInt128 values while maintaining the
ceiling behavior needed for fee padding.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@PhilWindle PhilWindle enabled auto-merge (squash) April 8, 2026 09:35
@PhilWindle PhilWindle merged commit 59f59f1 into merge-train/spartan Apr 9, 2026
25 checks passed
@PhilWindle PhilWindle deleted the danielntmd/a-797-gasfees-mul-precision branch April 9, 2026 08:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants