Skip to content

[Bug] Floating point arithmetic in base fee calculation #133

@qj0r9j0vc2

Description

@qj0r9j0vc2

Description

Base fee calculation uses floating point arithmetic which can cause precision loss with large values.

Location

let increase = (last_base_fee as f64 * 0.125 * (last_ratio - 0.5) * 2.0) as u128;
last_base_fee.saturating_add(increase)
} else {
// Block was less than 50% full, decrease base fee
let decrease = (last_base_fee as f64 * 0.125 * (0.5 - last_ratio) * 2.0) as u128;
last_base_fee.saturating_sub(decrease)

Severity

Medium - May cause fee calculation inconsistencies.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions